summary refs log tree commit diff stats
path: root/lib/wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wrappers')
-rw-r--r--lib/wrappers/claro.nim2748
-rw-r--r--lib/wrappers/expat.nim899
-rw-r--r--lib/wrappers/iup.nim10
-rw-r--r--lib/wrappers/joyent_http_parser.nim11
-rw-r--r--lib/wrappers/libcurl.nim512
-rw-r--r--lib/wrappers/libffi/common/ffi.h331
-rw-r--r--lib/wrappers/libffi/common/ffi_common.h77
-rw-r--r--lib/wrappers/libffi/common/fficonfig.h96
-rw-r--r--lib/wrappers/libffi/common/ffitarget.h150
-rw-r--r--lib/wrappers/libffi/common/malloc_closure.c110
-rw-r--r--lib/wrappers/libffi/common/raw_api.c254
-rw-r--r--lib/wrappers/libffi/gcc/closures.c627
-rw-r--r--lib/wrappers/libffi/gcc/ffi.c841
-rw-r--r--lib/wrappers/libffi/gcc/ffi64.c673
-rw-r--r--lib/wrappers/libffi/gcc/prep_cif.c237
-rw-r--r--lib/wrappers/libffi/gcc/types.c77
-rw-r--r--lib/wrappers/libffi/gcc/win32_asm.asm759
-rw-r--r--lib/wrappers/libffi/gcc/win32_asm.s736
-rw-r--r--lib/wrappers/libffi/gcc/win64_asm.asm467
-rw-r--r--lib/wrappers/libffi/gcc/win64_asm.s227
-rw-r--r--lib/wrappers/libffi/libffi.nim176
-rw-r--r--lib/wrappers/libffi/msvc/ffi.c457
-rw-r--r--lib/wrappers/libffi/msvc/prep_cif.c175
-rw-r--r--lib/wrappers/libffi/msvc/types.c104
-rw-r--r--lib/wrappers/libffi/msvc/win32.c162
-rw-r--r--lib/wrappers/libffi/msvc/win32_asm.asm470
-rw-r--r--lib/wrappers/libffi/msvc/win64_asm.asm156
-rw-r--r--lib/wrappers/libuv.nim11
-rw-r--r--lib/wrappers/odbcsql.nim358
-rw-r--r--lib/wrappers/openssl.nim148
-rw-r--r--lib/wrappers/pcre.nim41
-rw-r--r--lib/wrappers/pdcurses.nim1293
-rw-r--r--lib/wrappers/postgres.nim231
-rw-r--r--lib/wrappers/readline/history.nim279
-rw-r--r--lib/wrappers/readline/readline.nim1209
-rw-r--r--lib/wrappers/readline/rltypedefs.nim79
-rw-r--r--lib/wrappers/readline/tweaked/history.h257
-rw-r--r--lib/wrappers/readline/tweaked/readline.h956
-rw-r--r--lib/wrappers/readline/tweaked/rltypedefs.h78
-rw-r--r--lib/wrappers/readline/tweaked/tilde.h77
-rw-r--r--lib/wrappers/sdl/sdl.nim2579
-rw-r--r--lib/wrappers/sdl/sdl_gfx.nim452
-rw-r--r--lib/wrappers/sdl/sdl_image.nim243
-rw-r--r--lib/wrappers/sdl/sdl_mixer.nim489
-rw-r--r--lib/wrappers/sdl/sdl_mixer_nosmpeg.nim357
-rw-r--r--lib/wrappers/sdl/sdl_net.nim428
-rw-r--r--lib/wrappers/sdl/sdl_ttf.nim338
-rw-r--r--lib/wrappers/sdl/smpeg.nim335
-rw-r--r--lib/wrappers/sphinx.nim263
-rw-r--r--lib/wrappers/tre.nim188
-rw-r--r--lib/wrappers/zip/libzip.nim251
-rw-r--r--lib/wrappers/zip/libzip_all.c4189
-rw-r--r--lib/wrappers/zip/zlib.nim312
-rw-r--r--lib/wrappers/zip/zzip.nim176
54 files changed, 1048 insertions, 26111 deletions
diff --git a/lib/wrappers/claro.nim b/lib/wrappers/claro.nim
deleted file mode 100644
index 41956c28a..000000000
--- a/lib/wrappers/claro.nim
+++ /dev/null
@@ -1,2748 +0,0 @@
-# Claro Graphics - an abstraction layer for native UI libraries

-#  

-#  $Id$

-#  

-#  The contents of this file are subject to the Mozilla Public License

-#  Version 1.1 (the "License"); you may not use this file except in

-#  compliance with the License. You may obtain a copy of the License at

-#  http://www.mozilla.org/MPL/

-#  

-#  Software distributed under the License is distributed on an "AS IS"

-#  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the

-#  License for the specific language governing rights and limitations

-#  under the License.

-#  

-#  See the LICENSE file for more details.

-# 

-

-## Wrapper for the Claro GUI library. 

-## This wrapper calls ``claro_base_init`` and ``claro_graphics_init`` 

-## automatically on startup, so you don't have to do it and in fact cannot do

-## it because they are not exported.

-

-{.deadCodeElim: on.}

-

-when defined(windows): 

-  const 

-    clarodll = "claro.dll"

-elif defined(macosx): 

-  const 

-    clarodll = "libclaro.dylib"

-else: 

-  const 

-    clarodll = "libclaro.so"

-

-import cairo

-

-type 

-  Node* {.pure.} = object 

-    next*: ptr Node

-    prev*: ptr Node        # pointer to real structure 

-    data*: pointer

-

-  List* {.pure.} = object 

-    head*: ptr Node

-    tail*: ptr Node

-    count*: int32

-{.deprecated: [TNode: Node, TList: List].}

-

-proc list_init*(){.cdecl, importc: "list_init", dynlib: clarodll.}

-proc list_create*(list: ptr List){.cdecl, importc: "list_create", 

-                                      dynlib: clarodll.}

-proc node_create*(): ptr Node{.cdecl, importc: "node_create", 

-                                  dynlib: clarodll.}

-proc node_free*(n: ptr Node){.cdecl, importc: "node_free", dynlib: clarodll.}

-proc node_add*(data: pointer, n: ptr Node, L: ptr List){.cdecl, 

-    importc: "node_add", dynlib: clarodll.}

-proc node_prepend*(data: pointer, n: ptr Node, L: ptr List){.cdecl, 

-    importc: "node_prepend", dynlib: clarodll.}

-proc node_del*(n: ptr Node, L: ptr List){.cdecl, importc: "node_del", 

-    dynlib: clarodll.}

-proc node_find*(data: pointer, L: ptr List): ptr Node{.cdecl, 

-    importc: "node_find", dynlib: clarodll.}

-proc node_move*(n: ptr Node, oldlist: ptr List, newlist: ptr List){.

-    cdecl, importc: "node_move", dynlib: clarodll.}

-

-type 

-  ClaroObj*{.pure, inheritable.} = object 

-    typ*: array[0..64 - 1, char]

-    destroy_pending*: cint

-    event_handlers*: List

-    children*: List

-    parent*: ptr ClaroObj

-    appdata*: pointer         # !! this is for APPLICATION USE ONLY !! 

-  

-  Event*{.pure.} = object 

-    obj*: ptr ClaroObj    # the object which this event was sent to 

-    name*: array[0..64 - 1, char]

-    handled*: cint

-    arg_num*: cint            # number of arguments 

-    format*: array[0..16 - 1, char] # format of the arguments sent 

-    arglist*: ptr pointer     # list of args, as per format. 

-  

-  EventFunc* = proc (obj: ptr ClaroObj, event: ptr Event){.cdecl.}

-  EventIfaceFunc* = proc (obj: ptr ClaroObj, event: ptr Event, 

-                           data: pointer){.cdecl.}

-  EventHandler*{.pure.} = object 

-    typ*: array[0..32 - 1, char]

-    data*: pointer

-    fun*: EventFunc   # the function that handles this event 

-{.deprecated: [TEvent: Event, TEventFunc: EventFunc, TClaroObj: ClaroObj,

-              TEventIfaceFunc: EventIfaceFunc, TEventHandler: EventHandler].}

-

-# #define event_handler(n) void n ( ClaroObj *object, event_t *event )

-#CLVEXP list_t object_list;

-

-proc object_init*(){.cdecl, importc: "object_init", dynlib: clarodll.}

-

-proc object_override_next_size*(size: cint){.cdecl, 

-    importc: "object_override_next_size", dynlib: clarodll.}

-  ## Overrides the size of next object to be created, providing the 

-  ## size is more than is requested by default.

-  ## 

-  ## `size` specifies the full size, which is greater than both ClaroObj

-  ## and the size that will be requested automatically.

-    

-proc event_get_arg_ptr*(e: ptr Event, arg: cint): pointer{.cdecl, 

-    importc: "event_get_arg_ptr", dynlib: clarodll.}

-proc event_get_arg_double*(e: ptr Event, arg: cint): cdouble{.cdecl, 

-    importc: "event_get_arg_double", dynlib: clarodll.}

-proc event_get_arg_int*(e: ptr Event, arg: cint): cint{.cdecl, 

-    importc: "event_get_arg_int", dynlib: clarodll.}

-proc object_create*(parent: ptr ClaroObj, size: int32, 

-                    typ: cstring): ptr ClaroObj{.

-    cdecl, importc: "object_create", dynlib: clarodll.}

-proc object_destroy*(obj: ptr ClaroObj){.cdecl, importc: "object_destroy", 

-    dynlib: clarodll.}

-proc object_set_parent*(obj: ptr ClaroObj, parent: ptr ClaroObj){.cdecl, 

-    importc: "object_set_parent", dynlib: clarodll.}

-

-##define object_cmptype(o,t) (!strcmp(((ClaroObj *)o)->type,t))

-

-# event functions 

-

-proc object_addhandler*(obj: ptr ClaroObj, event: cstring, 

-                        fun: EventFunc){.cdecl, 

-    importc: "object_addhandler", dynlib: clarodll.}

-proc object_addhandler_interface*(obj: ptr ClaroObj, event: cstring, 

-                                  fun: EventFunc, data: pointer){.cdecl, 

-    importc: "object_addhandler_interface", dynlib: clarodll.}

-proc event_send*(obj: ptr ClaroObj, event: cstring, fmt: cstring): cint{.

-    varargs, cdecl, importc: "event_send", dynlib: clarodll.}

-proc event_get_name*(event: ptr Event): cstring{.cdecl, 

-    importc: "event_get_name", dynlib: clarodll.}

-proc claro_base_init(){.cdecl, importc: "claro_base_init", dynlib: clarodll.}

-proc claro_loop*(){.cdecl, importc: "claro_loop", dynlib: clarodll.}

-proc claro_run*(){.cdecl, importc: "claro_run", dynlib: clarodll.}

-proc claro_shutdown*(){.cdecl, importc: "claro_shutdown", dynlib: clarodll.}

-proc mssleep*(ms: cint){.cdecl, importc: "mssleep", dynlib: clarodll.}

-proc claro_graphics_init(){.cdecl, importc: "claro_graphics_init", 

-                            dynlib: clarodll.}

-

-const 

-  cWidgetNoBorder* = (1 shl 24)

-  cWidgetCustomDraw* = (1 shl 25)

-

-type 

-  Bounds*{.pure.} = object 

-    x*: cint

-    y*: cint

-    w*: cint

-    h*: cint

-    owner*: ptr ClaroObj

-{.deprecated: [TBounds: Bounds].}

-

-const 

-  cSizeRequestChanged* = 1

-

-type 

-  Font*{.pure.} = object 

-    used*: cint

-    face*: cstring

-    size*: cint

-    weight*: cint

-    slant*: cint

-    decoration*: cint

-    native*: pointer

-

-  Color*{.pure.} = object 

-    used*: cint

-    r*: cfloat

-    g*: cfloat

-    b*: cfloat

-    a*: cfloat

-

-  Widget* {.pure.} = object of ClaroObj

-    size_req*: ptr Bounds

-    size*: Bounds

-    size_ct*: Bounds

-    supports_alpha*: cint

-    size_flags*: cint

-    flags*: cint

-    visible*: cint

-    notify_flags*: cint

-    font*: Font

-    native*: pointer          # native widget 

-    ndata*: pointer           # additional native data 

-    container*: pointer       # native widget container (if not ->native) 

-    naddress*: array[0..3, pointer] # addressed for something 

-                                    # we override or need to remember 

-{.deprecated: [TFont: Font, TColor: Color, TWidget: Widget].}

-

-proc clipboard_set_text*(w: ptr Widget, text: cstring): cint{.cdecl, 

-    importc: "clipboard_set_text", dynlib: clarodll.}

-  ## Sets the (text) clipboard to the specified text value.

-  ##

-  ## `w` The widget requesting the action, some platforms may use this value.

-  ## `text` The text to place in the clipboard.

-  ## returns 1 on success, 0 on failure.

-

-const 

-  cNotifyMouse* = 1'i32

-  cNotifyKey* = 2'i32

-

-  cFontSlantNormal* = 0

-  cFontSlantItalic* = 1

-  cFontWeightNormal* = 0

-  cFontWeightBold* = 1

-  cFontDecorationNormal* = 0

-  cFontDecorationUnderline* = 1

-

-

-proc widget_set_font*(widget: ptr ClaroObj, face: cstring, size: cint, 

-                      weight: cint, slant: cint, decoration: cint){.cdecl, 

-    importc: "widget_set_font", dynlib: clarodll.}

-  ## Sets the font details of the specified widget.

-  ## 

-  ##  `widget` A widget

-  ##  `face` Font face string

-  ##  `size` Size of the font in pixels

-  ##  `weight` The weight of the font

-  ##  `slant` The sland of the font

-  ##  `decoration` The decoration of the font

-    

-proc widget_font_string_width*(widget: ptr ClaroObj, text: cstring, 

-                               chars: cint): cint {.

-    cdecl, importc: "widget_font_string_width", dynlib: clarodll.}

-  ## Calculates the pixel width of the text in the widget's font.

-  ## `chars` is the number of characters of text to calculate. Return value

-  ## is the width of the specified text in pixels.

-

-const 

-  CLARO_APPLICATION* = "claro.graphics"

-

-type 

-  Image* {.pure.} = object of ClaroObj

-    width*: cint

-    height*: cint

-    native*: pointer

-    native2*: pointer

-    native3*: pointer

-    icon*: pointer

-{.deprecated: [TImage: Image].}

-

-proc image_load*(parent: ptr ClaroObj, file: cstring): ptr Image{.cdecl, 

-    importc: "image_load", dynlib: clarodll.}

-  ## Loads an image from a file and returns a new image object.

-  ## 

-  ## The supported formats depend on the platform.

-  ## The main effort is to ensure that PNG images will always work.

-  ## Generally, JPEGs and possibly GIFs will also work.

-  ##

-  ## `Parent` object (usually the application's main window), can be nil.

-    

-proc image_load_inline_png*(parent: ptr ClaroObj, data: cstring, 

-                            len: cint): ptr Image{.cdecl, 

-    importc: "image_load_inline_png", dynlib: clarodll.}

-  ## Loads an image from inline data and returns a new image object.

-  ## `Parent` object (usually the application's main window), can be nil.

-  ##  data raw PNG image

-  ##  len size of data

-

-when true:

-  discard

-else:

-  # status icons are not supported on all platforms yet:

-  type 

-    StatusIcon* {.pure.} = object of ClaroObj

-      icon*: ptr Image

-      native*: pointer

-      native2*: pointer

-  {.deprecated: [TStatusIcon: StatusIcon].}

-

-  #*

-  #  \brief Creates a status icon

-  # 

-  #  \param parent Parent object (usually the application's main window),

-  #                can be NULL.

-  #  \param image The image object for the icon NOT NULL

-  #  \param flags Flags

-  #  \return New status_icon_t object

-  # 

-

-  proc status_icon_create*(parent: ptr ClaroObj, icon: ptr Image, 

-                           flags: cint): ptr StatusIcon {.

-      cdecl, importc: "status_icon_create", dynlib: clarodll.}

-

-  #*

-  #  \brief sets the status icon's image 

-  # 

-  #  \param status Status Icon

-  #  \param image The image object for the icon

-  # 

-

-  proc status_icon_set_icon*(status: ptr StatusIcon, icon: ptr Image){.cdecl, 

-      importc: "status_icon_set_icon", dynlib: clarodll.}

-

-  #*

-  #  \brief sets the status icons's menu

-  # 

-  #  \param status Status Icon

-  #  \param menu The menu object for the popup menu

-  # 

-

-  proc status_icon_set_menu*(status: ptr StatusIcon, menu: ptr ClaroObj){.cdecl, 

-      importc: "status_icon_set_menu", dynlib: clarodll.}

-  #*

-  #  \brief sets the status icon's visibility

-  # 

-  #  \param status Status Icon

-  #  \param visible whether the status icon is visible or not

-  # 

-

-  proc status_icon_set_visible*(status: ptr StatusIcon, visible: cint){.cdecl, 

-      importc: "status_icon_set_visible", dynlib: clarodll.}

-  #*

-  #  \brief sets the status icon's tooltip

-  # 

-  #  \param status Status Icon

-  #  \param tooltip Tooltip string

-  # 

-

-  proc status_icon_set_tooltip*(status: ptr StatusIcon, tooltip: cstring){.cdecl, 

-      importc: "status_icon_set_tooltip", dynlib: clarodll.}

-    

-#*

-#  \brief Makes the specified widget visible.

-# 

-#  \param widget A widget

-# 

-

-proc widget_show*(widget: ptr Widget){.cdecl, importc: "widget_show", 

-    dynlib: clarodll.}

-#*

-#  \brief Makes the specified widget invisible.

-# 

-#  \param widget A widget

-# 

-

-proc widget_hide*(widget: ptr Widget){.cdecl, importc: "widget_hide", 

-    dynlib: clarodll.}

-#*

-#  \brief Enables the widget, allowing focus

-# 

-#  \param widget A widget

-# 

-

-proc widget_enable*(widget: ptr Widget){.cdecl, importc: "widget_enable", 

-    dynlib: clarodll.}

-#*

-#  \brief Disables the widget

-#  When disabled, a widget appears greyed and cannot

-#  receive focus.

-# 

-#  \param widget A widget

-# 

-

-proc widget_disable*(widget: ptr Widget){.cdecl, importc: "widget_disable", 

-    dynlib: clarodll.}

-#*

-#  \brief Give focus to the specified widget

-# 

-#  \param widget A widget

-# 

-

-proc widget_focus*(widget: ptr Widget){.cdecl, importc: "widget_focus", 

-    dynlib: clarodll.}

-#*

-#  \brief Closes a widget

-# 

-#  Requests that a widget be closed by the platform code. 

-#  This may or may not result in immediate destruction of the widget,

-#  however the actual Claro widget object will remain valid until at

-#  least the next loop iteration.

-# 

-#  \param widget A widget

-# 

-

-proc widget_close*(widget: ptr Widget){.cdecl, importc: "widget_close", 

-    dynlib: clarodll.}

-#*

-#  \brief Retrieve the screen offset of the specified widget.

-# 

-#  Retrieves the X and Y screen positions of the widget.

-# 

-#  \param widget A widget

-#  \param dx Pointer to the location to place the X position.

-#  \param dy Pointer to the location to place the Y position.

-# 

-

-proc widget_screen_offset*(widget: ptr Widget, dx: ptr cint, dy: ptr cint){.

-    cdecl, importc: "widget_screen_offset", dynlib: clarodll.}

-#*

-#  \brief Sets the additional notify events that should be sent.

-# 

-#  For performance reasons, some events, like mouse and key events,

-#  are not sent by default. By specifying such events here, you can

-#  elect to receive these events.

-# 

-#  \param widget A widget

-#  \param flags Any number of cWidgetNotify flags ORed together.

-# 

-

-proc widget_set_notify*(widget: ptr Widget, flags: cint){.cdecl, 

-    importc: "widget_set_notify", dynlib: clarodll.}

-

-

-type

-  CursorType* {.size: sizeof(cint).} = enum

-    cCursorNormal = 0,

-    cCursorTextEdit = 1,

-    cCursorWait = 2,

-    cCursorPoint = 3

-{.deprecated: [TCursorType: CursorType].}

-

-#*

-#  \brief Sets the mouse cursor for the widget

-# 

-#  \param widget A widget

-#  \param cursor A valid cCursor* value

-# 

-

-proc widget_set_cursor*(widget: ptr Widget, cursor: CursorType){.cdecl, 

-    importc: "widget_set_cursor", dynlib: clarodll.}

-

-#*

-#  \brief Retrieves the key pressed in a key notify event.

-# 

-#  \param widget A widget

-#  \param event An event resource

-#  \return The keycode of the key pressed.

-# 

-

-proc widget_get_notify_key*(widget: ptr Widget, event: ptr Event): cint{.

-    cdecl, importc: "widget_get_notify_key", dynlib: clarodll.}

-

-#*

-#  \brief Updates the bounds structure with new values

-# 

-#  This function should \b always be used instead of setting the

-#  members manually. In the future, there may be a \b real reason

-#  for this.

-# 

-#  \param bounds A bounds structure

-#  \param x The new X position

-#  \param y The new Y position

-#  \param w The new width

-#  \param h The new height

-# 

-

-proc bounds_set*(bounds: ptr Bounds, x: cint, y: cint, w: cint, h: cint){.

-    cdecl, importc: "bounds_set", dynlib: clarodll.}

-#*

-#  \brief Create a new bounds object

-# 

-#  Creates a new bounds_t for the specified bounds.

-# 

-#  \param x X position

-#  \param y Y position

-#  \param w Width

-#  \param h Height

-#  \return A new bounds_t structure

-# 

-

-proc new_bounds*(x: cint, y: cint, w: cint, h: cint): ptr Bounds{.cdecl, 

-    importc: "new_bounds", dynlib: clarodll.}

-proc get_req_bounds*(widget: ptr Widget): ptr Bounds{.cdecl, 

-    importc: "get_req_bounds", dynlib: clarodll.}

-    

-var

-  noBoundsVar: Bounds # set to all zero which is correct

-    

-template noBounds*: expr = (addr(bind noBoundsVar))

-

-#* \internal

-#  \brief Internal pre-inititalisation hook

-# 

-#  \param widget A widget

-# 

-

-proc widget_pre_init*(widget: ptr Widget){.cdecl, importc: "widget_pre_init", 

-    dynlib: clarodll.}

-#* \internal

-#  \brief Internal post-inititalisation hook

-# 

-#  \param widget A widget

-# 

-

-proc widget_post_init*(widget: ptr Widget){.cdecl, 

-    importc: "widget_post_init", dynlib: clarodll.}

-#* \internal

-#  \brief Internal resize event handler

-# 

-#  \param obj An object

-#  \param event An event resource

-# 

-

-proc widget_resized_handle*(obj: ptr Widget, event: ptr Event){.cdecl, 

-    importc: "widget_resized_handle", dynlib: clarodll.}

-# CLVEXP bounds_t no_bounds;

-#* \internal

-#  \brief Internal default widget creation function

-# 

-#  \param parent The parent of the widget

-#  \param widget_size The size in bytes of the widget's structure

-#  \param widget_name The object type of the widget (claro.graphics.widgets.*)

-#  \param size_req The initial bounds of the widget

-#  \param flags Widget flags

-#  \param creator The platform function that will be called to actually create

-#                 the widget natively.

-#  \return A new widget object

-# 

-

-type

-  CgraphicsCreateFunction* = proc (widget: ptr Widget) {.cdecl.}

-{.deprecated: [TcgraphicsCreateFunction: CgraphicsCreateFunction].}

-

-proc newdefault*(parent: ptr Widget, widget_size: int, 

-                 widget_name: cstring, size_req: ptr Bounds, flags: cint, 

-                 creator: CgraphicsCreateFunction): ptr Widget{.cdecl, 

-    importc: "default_widget_create", dynlib: clarodll.}

-#* \internal

-#  \brief Retrieves the native container of the widget's children

-# 

-#  \param widget A widget

-#  \return A pointer to the native widget that will hold w's children

-# 

-

-proc widget_get_container*(widget: ptr Widget): pointer{.cdecl, 

-    importc: "widget_get_container", dynlib: clarodll.}

-#* \internal

-#  \brief Sets the content size of the widget.

-# 

-#  \param widget A widget

-#  \param w New width of the content area of the widget

-#  \param h New height of the content area of the widget

-#  \param event Whether to send a content_size event

-# 

-

-proc widget_set_content_size*(widget: ptr Widget, w: cint, h: cint, 

-                              event: cint){.cdecl, 

-    importc: "widget_set_content_size", dynlib: clarodll.}

-#* \internal

-#  \brief Sets the size of the widget.

-# 

-#  \param widget A widget

-#  \param w New width of the widget

-#  \param h New height of the widget

-#  \param event Whether to send a resize event

-# 

-

-proc widget_set_size*(widget: ptr Widget, w: cint, h: cint, event: cint){.

-    cdecl, importc: "widget_set_size", dynlib: clarodll.}

-#* \internal

-#  \brief Sets the position of the widget's content area.

-# 

-#  \param widget A widget

-#  \param x New X position of the widget's content area

-#  \param y New Y position of the widget's content area

-#  \param event Whether to send a content_move event

-# 

-

-proc widget_set_content_position*(widget: ptr Widget, x: cint, y: cint, 

-                                  event: cint){.cdecl, 

-    importc: "widget_set_content_position", dynlib: clarodll.}

-#* \internal

-#  \brief Sets the position of the widget.

-# 

-#  \param widget A widget

-#  \param x New X position of the widget's content area

-#  \param y New Y position of the widget's content area

-#  \param event Whether to send a moved event

-# 

-

-proc widget_set_position*(widget: ptr Widget, x: cint, y: cint, event: cint){.

-    cdecl, importc: "widget_set_position", dynlib: clarodll.}

-#* \internal

-#  \brief Sends a destroy event to the specified widget.

-# 

-#  You should use widget_close() in application code instead.

-# 

-#  \param widget A widget

-# 

-

-proc widget_destroy*(widget: ptr Widget){.cdecl, importc: "widget_destroy", 

-    dynlib: clarodll.}

-

-type 

-  OpenglWidget* {.pure.} = object of Widget

-    gldata*: pointer

-{.deprecated: [TOpenglWidget: OpenglWidget].}

-

-# functions 

-#*

-#  \brief Creates a OpenGL widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new OpenGL widget object.

-# 

-

-proc newopengl*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                flags: cint): ptr OpenglWidget {.

-    cdecl, importc: "opengl_widget_create", dynlib: clarodll.}

-#*

-#  \brief Flips the front and back buffers

-#  

-#  \param widget A valid OpenGL widget object

-# 

-

-proc opengl_flip*(widget: ptr OpenglWidget) {.cdecl, importc: "opengl_flip", 

-    dynlib: clarodll.}

-#*

-#  \brief Activates this OpenGL widget's context

-#  

-#  \param widget A valid OpenGL widget object

-# 

-

-proc opengl_activate*(widget: ptr OpenglWidget) {.

-    cdecl, importc: "opengl_activate", dynlib: clarodll.}

-

-type 

-  Button* {.pure.} = object of Widget

-    text*: array[0..256-1, char]

-{.deprecated: [TButton: Button].}

-

-# functions 

-#*

-#  \brief Creates a Button widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Button widget object.

-# 

-

-proc newbutton*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                flags: cint): ptr Button {.

-    cdecl, importc: "button_widget_create", dynlib: clarodll.}

-#*

-#  \brief Creates a Button widget with a label

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \param label The label for the button

-#  \return A new Button widget object.

-# 

-

-proc newbutton*(parent: ptr ClaroObj, 

-                bounds: ptr Bounds, flags: cint, 

-                label: cstring): ptr Button{.cdecl, 

-    importc: "button_widget_create_with_label", dynlib: clarodll.}

-#*

-#  \brief Changes the label of the button

-#  

-#  \param obj A valid Button widget object

-#  \param label The new label for the button

-# 

-

-proc button_set_text*(obj: ptr Button, label: cstring){.cdecl, 

-    importc: "button_set_label", dynlib: clarodll.}

-

-#*

-#  \brief Changes the image of the button

-# 

-#  \warning This function is not implemented yet and is not portable.

-#           Do not use it.

-#  

-#  \param obj A valid Button widget object

-#  \param image The new image for the button

-# 

-

-proc button_set_image*(obj: ptr Button, image: ptr Image){.cdecl, 

-    importc: "button_set_image", dynlib: clarodll.}

-

-const 

-  CTEXT_SLANT_NORMAL* = cFontSlantNormal

-  CTEXT_SLANT_ITALIC* = cFontSlantItalic

-  CTEXT_WEIGHT_NORMAL* = cFontWeightNormal

-  CTEXT_WEIGHT_BOLD* = cFontWeightBold

-  CTEXT_EXTRA_NONE* = cFontDecorationNormal

-  CTEXT_EXTRA_UNDERLINE* = cFontDecorationUnderline

-

-# END OLD 

-

-type 

-  Canvas*{.pure.} = object of Widget

-    surface*: cairo.PSurface

-    cr*: cairo.PContext

-    surfdata*: pointer

-    fontdata*: pointer

-    font_height*: cint

-    fr*: cfloat

-    fg*: cfloat

-    fb*: cfloat

-    fa*: cfloat

-    br*: cfloat

-    bg*: cfloat

-    bb*: cfloat

-    ba*: cfloat

-    charsize*: array[0..256 - 1, cairo.TTextExtents]

-    csz_loaded*: cint

-    fontsize*: cint

-{.deprecated: [TCanvas: Canvas].}

-

-# functions 

-#*

-#  \brief Creates a Canvas widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Canvas widget object.

-# 

-

-proc newcanvas*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                flags: cint): ptr Canvas{.

-    cdecl, importc: "canvas_widget_create", dynlib: clarodll.}

-#*

-#  \brief Invalidates and redraws a canvas widget

-#  

-#  \param widget A valid Canvas widget object.

-# 

-

-proc canvas_redraw*(widget: ptr Canvas){.cdecl, importc: "canvas_redraw", 

-    dynlib: clarodll.}

-# claro text functions 

-#*

-#  \brief Set the current text color

-#  

-#  \param widget A valid Canvas widget object.

-#  \param r Red component (0.0 - 1.0)

-#  \param g Green component (0.0 - 1.0)

-#  \param b Blue component (0.0 - 1.0)

-#  \param a Alpha component (0.0 - 1.0)

-# 

-

-proc canvas_set_text_color*(widget: ptr Canvas, r: cdouble, g: cdouble, 

-                            b: cdouble, a: cdouble){.cdecl, 

-    importc: "canvas_set_text_color", dynlib: clarodll.}

-#*

-#  \brief Set the current text background color

-#  

-#  \param widget A valid Canvas widget object.

-#  \param r Red component (0.0 - 1.0)

-#  \param g Green component (0.0 - 1.0)

-#  \param b Blue component (0.0 - 1.0)

-#  \param a Alpha component (0.0 - 1.0)

-# 

-

-proc canvas_set_text_bgcolor*(widget: ptr Canvas, r: cdouble, g: cdouble, 

-                              b: cdouble, a: cdouble){.cdecl, 

-    importc: "canvas_set_text_bgcolor", dynlib: clarodll.}

-#*

-#  \brief Set the current canvas font

-#  

-#  \param widget A valid Canvas widget object.

-#  \param face The font face

-#  \param size The font height in pixels

-#  \param weight The weight of the font

-#  \param slant The slant of the font

-#  \param decoration Font decorations

-# 

-

-proc canvas_set_text_font*(widget: ptr Canvas, face: cstring, size: cint, 

-                           weight: cint, slant: cint, decoration: cint){.cdecl, 

-    importc: "canvas_set_text_font", dynlib: clarodll.}

-#*

-#  \brief Calculates the width of the specified text

-#  

-#  \param widget A valid Canvas widget object.

-#  \param text The text to calulate the length of

-#  \param len The number of characters of text to calulcate

-#  \return Width of the text in pixels

-# 

-

-proc canvas_text_width*(widget: ptr Canvas, text: cstring, len: cint): cint{.

-    cdecl, importc: "canvas_text_width", dynlib: clarodll.}

-#*

-#  \brief Calculates the width of the specified text's bounding box

-#  

-#  \param widget A valid Canvas widget object.

-#  \param text The text to calulate the length of

-#  \param len The number of characters of text to calulcate

-#  \return Width of the text's bounding box in pixels

-# 

-

-proc canvas_text_box_width*(widget: ptr Canvas, text: cstring, 

-                            len: cint): cint{.

-    cdecl, importc: "canvas_text_box_width", dynlib: clarodll.}

-#*

-#  \brief Calculates the number of characters of text that can be displayed

-#         before width pixels.

-#  

-#  \param widget A valid Canvas widget object.

-#  \param text The text to calulate the length of

-#  \param width The width to fit the text in

-#  \return The number of characters of text that will fit in width pixels.

-# 

-

-proc canvas_text_display_count*(widget: ptr Canvas, text: cstring, 

-                                width: cint): cint{.cdecl, 

-    importc: "canvas_text_display_count", dynlib: clarodll.}

-#*

-#  \brief Displays the specified text on the canvas

-#  

-#  \param widget A valid Canvas widget object.

-#  \param x The X position at which the text will be drawn

-#  \param y The Y position at which the text will be drawn

-#  \param text The text to calulate the length of

-#  \param len The number of characters of text to calulcate

-# 

-

-proc canvas_show_text*(widget: ptr Canvas, x: cint, y: cint, text: cstring, 

-                       len: cint){.cdecl, importc: "canvas_show_text", 

-                                   dynlib: clarodll.}

-#*

-#  \brief Draws a filled rectangle

-#  

-#  \param widget A valid Canvas widget object.

-#  \param x The X position at which the rectangle will start

-#  \param y The Y position at which the rectangle will start

-#  \param w The width of the rectangle

-#  \param h The height of the rectangle

-#  \param r Red component (0.0 - 1.0)

-#  \param g Green component (0.0 - 1.0)

-#  \param b Blue component (0.0 - 1.0)

-#  \param a Alpha component (0.0 - 1.0)

-# 

-

-proc canvas_fill_rect*(widget: ptr Canvas, x: cint, y: cint, w: cint, 

-                       h: cint, r, g, b, a: cdouble){.

-    cdecl, importc: "canvas_fill_rect", dynlib: clarodll.}

-#*

-#  \brief Draws the specified image on the canvas

-#  

-#  \param widget A valid Canvas widget object.

-#  \param image The image to draw

-#  \param x The X position at which the image will be drawn

-#  \param y The Y position at which the image will be drawn

-# 

-

-proc canvas_draw_image*(widget: ptr Canvas, image: ptr Image, x: cint, 

-                        y: cint){.cdecl, importc: "canvas_draw_image", 

-                                  dynlib: clarodll.}

-# claro "extensions" of cairo 

-#* \internal

-#  \brief Internal claro extension of cairo text functions

-# 

-

-proc canvas_cairo_buffered_text_width*(widget: ptr Canvas, 

-                                       text: cstring, len: cint): cint{.cdecl, 

-    importc: "canvas_cairo_buffered_text_width", dynlib: clarodll.}

-#* \internal

-#  \brief Internal claro extension of cairo text functions

-# 

-

-proc canvas_cairo_buffered_text_display_count*(widget: ptr Canvas, 

-    text: cstring, width: cint): cint{.cdecl, 

-    importc: "canvas_cairo_buffered_text_display_count", 

-    dynlib: clarodll.}

-proc canvas_get_cairo_context*(widget: ptr Canvas): cairo.PContext {.cdecl, 

-    importc: "canvas_get_cairo_context", dynlib: clarodll.}

-

-type 

-  CheckBox*{.pure.} = object of Widget

-    text*: array[0..256-1, char]

-    checked*: cint

-{.deprecated: [TCheckBox: CheckBox].}

-#*

-#  \brief Creates a Checkbox widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Checkbox widget object.

-# 

-

-proc newcheckbox*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                  flags: cint): ptr CheckBox{.

-    cdecl, importc: "checkbox_widget_create", dynlib: clarodll.}

-#*

-#  \brief Creates a Checkbox widget with a label

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \param label The label for the checkbox

-#  \return A new Checkbox widget object.

-# 

-

-proc newcheckbox*(parent: ptr ClaroObj, 

-                  bounds: ptr Bounds, flags: cint, 

-                  label: cstring): ptr CheckBox {.cdecl, 

-    importc: "checkbox_widget_create_with_label", dynlib: clarodll.}

-#*

-#  \brief Sets a new label for the Checkbox widget

-#  

-#  \param obj A valid Checkbox widget object.

-#  \param label The new label for the checkbox

-# 

-

-proc checkbox_set_text*(obj: ptr CheckBox, label: cstring){.cdecl, 

-    importc: "checkbox_set_label", dynlib: clarodll.}

-#*

-#  \brief Retrieves the checkbox's check state

-#  

-#  \param obj A valid Checkbox widget object.

-#  \return 1 if the checkbox is checked, otherwise 0

-# 

-

-proc checkbox_checked*(obj: ptr CheckBox): cint{.cdecl, 

-    importc: "checkbox_get_checked", dynlib: clarodll.}

-#*

-#  \brief Sets the checkbox's checked state

-#  

-#  \param obj A valid Checkbox widget object.

-#  \param checked 1 if the checkbox should become checked, otherwise 0

-# 

-

-proc checkbox_set_checked*(obj: ptr CheckBox, checked: cint){.cdecl, 

-    importc: "checkbox_set_checked", dynlib: clarodll.}

-

-

-#*

-#  List items define items in a list_widget

-# 

-

-type 

-  ListItem*{.pure.} = object of ClaroObj

-    row*: cint

-    native*: pointer

-    nativeid*: int

-    menu*: ptr ClaroObj

-    enabled*: cint

-    data*: ptr pointer

-    ListItemChildren*: List

-    ListItemParent*: ptr List

-    parent_item*: ptr ListItem # drawing related info, not always required

-    text_color*: Color

-    sel_text_color*: Color

-    back_color*: Color

-    sel_back_color*: Color

-    font*: Font

-

-  ListWidget* {.pure.} = object of Widget ## List widget, base for 

-                                            ## widgets containing items

-    columns*: cint

-    coltypes*: ptr cint

-    items*: List

-

-  Combo*{.pure.} = object of ListWidget

-    selected*: ptr ListItem

-{.deprecated: [TListItem: ListItem, TListWidget: ListWidget, TCombo: Combo].}

-

-# functions 

-#*

-#  \brief Creates a Combo widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Combo widget object.

-# 

-

-proc newcombo*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-               flags: cint): ptr Combo{.

-    cdecl, importc: "combo_widget_create", dynlib: clarodll.}

-#*

-#  \brief Append a row to a Combo widget

-#  

-#  \param combo A valid Combo widget object.

-#  \param text The text for the item.

-#  \return A new list item.

-# 

-

-proc combo_append_row*(combo: ptr Combo, text: cstring): ptr ListItem {.

-    cdecl, importc: "combo_append_row", dynlib: clarodll.}

-#*

-#  \brief Insert a row at the specified position into a Combo widget

-#  

-#  \param combo A valid Combo widget object.

-#  \param pos The index at which this item will be placed.

-#  \param text The text for the item.

-#  \return A new list item.

-# 

-

-proc combo_insert_row*(combo: ptr Combo, pos: cint, 

-                       text: cstring): ptr ListItem {.

-    cdecl, importc: "combo_insert_row", dynlib: clarodll.}

-#*

-#  \brief Move a row in a Combo widget

-#  

-#  \param combo A valid Combo widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc combo_move_row*(combo: ptr Combo, item: ptr ListItem, row: cint){.

-    cdecl, importc: "combo_move_row", dynlib: clarodll.}

-#*

-#  \brief Remove a row from a Combo widget

-#  

-#  \param combo A valid Combo widget object.

-#  \param item A valid list item

-# 

-

-proc combo_remove_row*(combo: ptr Combo, item: ptr ListItem){.cdecl, 

-    importc: "combo_remove_row", dynlib: clarodll.}

-#*

-#  \brief Returns the currently selected Combo item

-#  

-#  \param obj A valid Combo widget object.

-#  \return The currently selected Combo item, or NULL if no item is selected.

-# 

-

-proc combo_get_selected*(obj: ptr Combo): ptr ListItem{.cdecl, 

-    importc: "combo_get_selected", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a Combo widget

-#  

-#  \param obj A valid Combo widget object.

-#  \return Number of rows

-# 

-

-proc combo_get_rows*(obj: ptr Combo): cint{.cdecl, 

-    importc: "combo_get_rows", dynlib: clarodll.}

-#*

-#  \brief Selects a row in a Combo widget

-#  

-#  \param obj A valid Combo widget object.

-#  \param item A valid list item

-# 

-

-proc combo_select_item*(obj: ptr Combo, item: ptr ListItem){.cdecl, 

-    importc: "combo_select_item", dynlib: clarodll.}

-#*

-#  \brief Removes all entries from a Combo widget

-#  

-#  \param obj A valid Combo widget object.

-# 

-

-proc combo_clear*(obj: ptr Combo){.cdecl, importc: "combo_clear", 

-                                    dynlib: clarodll.}

-

-type 

-  ContainerWidget* {.pure.} = object of Widget

-{.deprecated: [TContainerWidget: ContainerWidget].}

-

-

-# functions 

-#*

-#  \brief Creates a Container widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Container widget object.

-# 

-

-proc newcontainer*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                   flags: cint): ptr ContainerWidget{.

-    cdecl, importc: "container_widget_create", dynlib: clarodll.}

-

-proc newdialog*(parent: ptr ClaroObj, bounds: ptr Bounds, format: cstring, 

-                flags: cint): ptr ClaroObj{.cdecl, 

-    importc: "dialog_widget_create", dynlib: clarodll.}

-proc dialog_set_text*(obj: ptr ClaroObj, text: cstring){.cdecl, 

-    importc: "dialog_set_text", dynlib: clarodll.}

-proc dialog_set_default_icon*(typ: cstring, file: cstring){.cdecl, 

-    importc: "dialog_set_default_icon", dynlib: clarodll.}

-proc dialog_get_default_icon*(dialog_type: cint): cstring{.cdecl, 

-    importc: "dialog_get_default_icon", dynlib: clarodll.}

-proc dialog_warning*(format: cstring, text: cstring): cint{.cdecl, 

-    importc: "dialog_warning", dynlib: clarodll.}

-proc dialog_info*(format: cstring, text: cstring): cint{.cdecl, 

-    importc: "dialog_info", dynlib: clarodll.}

-proc dialog_error*(format: cstring, text: cstring): cint{.cdecl, 

-    importc: "dialog_error", dynlib: clarodll.}

-proc dialog_other*(format: cstring, text: cstring, default_icon: cstring): cint{.

-    cdecl, importc: "dialog_other", dynlib: clarodll.}

-

-type 

-  FontDialog* {.pure.} = object of Widget

-    selected*: Font

-{.deprecated: [TFontDialog: FontDialog].}

-

-# functions 

-#*

-#  \brief Creates a Font Selection widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new Font Selection widget object.

-# 

-

-proc newFontDialog*(parent: ptr ClaroObj, flags: cint): ptr FontDialog {.

-    cdecl, importc: "font_dialog_widget_create", dynlib: clarodll.}

-#*

-#  \brief Changes the selected font

-#  

-#  \param obj A valid Font Selection widget object

-#  \param font The name of the font

-# 

-

-proc font_dialog_set_font*(obj: ptr FontDialog, face: cstring, size: cint, 

-                           weight: cint, slant: cint, decoration: cint){.cdecl, 

-    importc: "font_dialog_set_font", dynlib: clarodll.}

-#*

-#  \brief Returns a structure representing the currently selected font

-#  

-#  \param obj A valid Font Selection widget object

-#  \return A font_t structure containing information about the selected font.

-# 

-

-proc font_dialog_get_font*(obj: ptr FontDialog): ptr Font{.cdecl, 

-    importc: "font_dialog_get_font", dynlib: clarodll.}

-

-type 

-  Frame* {.pure.} = object of Widget

-    text*: array[0..256-1, char]

-{.deprecated: [TFrame: Frame].}

-

-#*

-#  \brief Creates a Frame widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Frame widget object.

-# 

-

-proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-               flags: cint): ptr Frame{.

-    cdecl, importc: "frame_widget_create", dynlib: clarodll.}

-#*

-#  \brief Creates a Frame widget with a label

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \param label The initial label for the frame

-#  \return A new Frame widget object.

-# 

-

-proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds, flags: cint, 

-                                     label: cstring): ptr Frame {.cdecl, 

-    importc: "frame_widget_create_with_label", dynlib: clarodll.}

-#*

-#  \brief Creates a Container widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Container widget object.

-# 

-

-proc frame_set_text*(frame: ptr Frame, label: cstring){.cdecl, 

-    importc: "frame_set_label", dynlib: clarodll.}

-

-type 

-  ImageWidget* {.pure.} = object of Widget

-    src*: ptr Image

-{.deprecated: [TImageWidget: ImageWidget].}

-

-#*

-#  \brief Creates an Image widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Image widget object.

-# 

-

-proc newimageWidget*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                     flags: cint): ptr ImageWidget{.

-    cdecl, importc: "image_widget_create", dynlib: clarodll.}

-#*

-#  \brief Creates an Image widget with an image

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \param image A valid Image object.

-#  \return A new Image widget object.

-# 

-

-proc newimageWidget*(parent: ptr ClaroObj, 

-                     bounds: ptr Bounds, flags: cint, 

-                     image: ptr Image): ptr ImageWidget{.cdecl, 

-    importc: "image_widget_create_with_image", dynlib: clarodll.}

-#*

-#  \brief Sets the image object of the image widget

-#  

-#  \param image A valid image widget

-#  \param src The source image object

-# 

-

-proc image_set_image*(image: ptr ImageWidget, src: ptr Image){.cdecl, 

-    importc: "image_set_image", dynlib: clarodll.}

-    

-type 

-  Label*{.pure.} = object of Widget

-    text*: array[0..256-1, char]

-

-  CLabelJustify* = enum 

-    cLabelLeft = 0x00000001, cLabelRight = 0x00000002, 

-    cLabelCenter = 0x00000004, cLabelFill = 0x00000008

-{.deprecated: [TLabel: Label, TcLabelJustify: CLabelJustify].}

-

-#*

-#  \brief Creates a Label widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Label widget object.

-# 

-

-proc newlabel*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-               flags: cint): ptr Label{.

-    cdecl, importc: "label_widget_create", dynlib: clarodll.}

-#*

-#  \brief Creates a Label widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Label widget object.

-# 

-

-proc newLabel*(parent: ptr ClaroObj, 

-               bounds: ptr Bounds, flags: cint, 

-               text: cstring): ptr Label{.cdecl, 

-    importc: "label_widget_create_with_text", dynlib: clarodll.}

-#*

-#  \brief Sets the text of a label widget

-#  

-#  \param obj A valid label widget

-#  \param text The text this label widget will show

-# 

-

-proc label_set_text*(obj: ptr Label, text: cstring){.cdecl, 

-    importc: "label_set_text", dynlib: clarodll.}

-    

-#*

-#  \brief Sets the alignment/justification of a label

-#  

-#  \param obj A valid label widget

-#  \param text The justification (see cLabelJustify enum)

-# 

-

-proc label_set_justify*(obj: ptr Label, flags: cint){.cdecl, 

-    importc: "label_set_justify", dynlib: clarodll.}

-    

-const 

-  CLIST_TYPE_PTR* = 0

-  CLIST_TYPE_STRING* = 1

-  CLIST_TYPE_INT* = 2

-  CLIST_TYPE_UINT* = 3

-  CLIST_TYPE_DOUBLE* = 4

-

-# functions 

-#*

-#  \brief Initialises a list_widget_t derivative's storage space.

-# 

-#  \param obj list widget

-#  \param col_num number of columns to be used

-#  \param cols An array of col_num integers, specifying the 

-#              types of the columns.

-# 

-

-proc list_widget_init_ptr*(obj: ptr ListWidget, col_num: cint, 

-                           cols: ptr cint) {.cdecl, 

-    importc: "list_widget_init_ptr", dynlib: clarodll.}

-#*

-#  \brief Copies and passes on the arg list to list_widget_init_ptr.

-# 

-#  \param obj list widget

-#  \param col_num number of columns to be used

-#  \param argpi A pointer to a va_list to parse

-# 

-

-#proc list_widget_init_vaptr*(obj: ptr ClaroObj, col_num: cunsignedint, 

-#                             argpi: va_list){.cdecl, 

-#    importc: "list_widget_init_vaptr", dynlib: clarodll.}

-

-#*

-#  Shortcut function, simply calls list_widget_init_ptr with

-#  it's own arguments, and a pointer to the first variable argument.

-# 

-

-proc list_widget_init*(obj: ptr ListWidget, col_num: cint){.varargs, 

-    cdecl, importc: "list_widget_init", dynlib: clarodll.}

-#*

-#  \brief Inserts a row to a list under parent at the position specified.

-# 

-#  \param list list to insert item in

-#  \param parent item in tree to be used as parent. NULL specifies

-#   that it should be a root node.

-#  \param row item will be inserted before the item currently at

-#   this position. -1 specifies an append.

-#  \param argp points to the first element of an array containing

-#  the column data as specified by the types in list_widget_init.

-# 

-

-#*

-#  Shortcut function, calls list_widget_row_insert_ptr with

-#  it's own arguments, a position at the end of the list, and

-#  a pointer to the first variable argument.

-# 

-

-proc list_widget_row_append*(list: ptr ListWidget, 

-                             parent: ptr ListItem): ptr ListItem{.

-    varargs, cdecl, importc: "list_widget_row_append", dynlib: clarodll.}

-#*

-#  Shortcut function, calls list_widget_row_insert_ptr with

-#  it's own arguments, and a pointer to the first variable argument.

-# 

-

-proc list_widget_row_insert*(list: ptr ListWidget, parent: ptr ListItem, 

-                             pos: cint): ptr ListItem {.varargs, cdecl, 

-    importc: "list_widget_row_insert", dynlib: clarodll.}

-#*

-#  \brief Removes a row from a list

-# 

-#  \param list List widget to operate on

-#  \param item The item to remove

-# 

-

-proc list_widget_row_remove*(list: ptr ListWidget, item: ptr ListItem){.

-    cdecl, importc: "list_widget_row_remove", dynlib: clarodll.}

-#*

-#  \brief Moves a row to a new position in the list

-# 

-#  \param list List widget to operate on

-#  \param item The item to move 

-#  \param row Row position to place item before. Passing the current

-#             position will result in no change.

-# 

-

-proc list_widget_row_move*(list: ptr ListWidget, item: ptr ListItem, 

-                           row: cint){.cdecl, importc: "list_widget_row_move", 

-                                       dynlib: clarodll.}

-#*

-#  \brief Return the nth row under parent in the list

-# 

-#  \param list List widget search

-#  \param parent Parent of the item

-#  \param row Row index of item to return

-# 

-

-proc list_widget_get_row*(list: ptr ListWidget, parent: ptr ListItem, 

-                          row: cint): ptr ListItem{.cdecl, 

-    importc: "list_widget_get_row", dynlib: clarodll.}

-#*

-#  \brief Edit items of a row in the list.

-# 

-#  \param list List widget to edit

-#  \param item Row to modify

-#  \param args num,val,...,-1 where num is the column and val is the new 

-#              value of the column's type. Terminate with -1. 

-#              Don't forget the -1.

-# 

-

-#*

-#  \brief Edit items of a row in the list.

-# 

-#  \param list List-based (list_widget_t) object

-#  \param item Row to modify

-#  \param ... num,val,...,-1 where num is the column and val is the new 

-#              value of the column's type. Terminate with -1. 

-#              Don't forget the -1.

-# 

-

-proc list_widget_edit_row*(list: ptr ListWidget, item: ptr ListItem){.

-    varargs, cdecl, importc: "list_widget_edit_row", dynlib: clarodll.}

-#*

-#  \brief Set the text color of an item.

-#  This is currently only supported by the TreeView widget.

-# 

-#  \param item Target list item

-#  \param r Red component between 0.0 and 1.0

-#  \param g Green component between 0.0 and 1.0

-#  \param b Blue component between 0.0 and 1.0

-#  \param a Alpha component between 0.0 and 1.0 (reserved for future use,

-#          should be 1.0)

-# 

-

-proc list_item_set_text_color*(item: ptr ListItem, r: cfloat, g: cfloat, 

-                               b: cfloat, a: cfloat){.cdecl, 

-    importc: "list_item_set_text_color", dynlib: clarodll.}

-#*

-#  \brief Set the text background color of an item.

-#  This is currently only supported by the TreeView widget.

-# 

-#  \param item Target list item

-#  \param r Red component between 0.0 and 1.0

-#  \param g Green component between 0.0 and 1.0

-#  \param b Blue component between 0.0 and 1.0

-#  \param a Alpha component between 0.0 and 1.0 (reserved for future use,

-#           should be 1.0)

-# 

-

-proc list_item_set_text_bgcolor*(item: ptr ListItem, r: cfloat, g: cfloat, 

-                                 b: cfloat, a: cfloat){.cdecl, 

-    importc: "list_item_set_text_bgcolor", dynlib: clarodll.}

-#*

-#  \brief Set the text color of a selected item.

-#  This is currently only supported by the TreeView widget.

-# 

-#  \param item Target list item

-#  \param r Red component between 0.0 and 1.0

-#  \param g Green component between 0.0 and 1.0

-#  \param b Blue component between 0.0 and 1.0

-#  \param a Alpha component between 0.0 and 1.0 (reserved for future use,

-#         should be 1.0)

-# 

-

-proc list_item_set_sel_text_color*(item: ptr ListItem, r: cfloat, g: cfloat, 

-                                   b: cfloat, a: cfloat){.cdecl, 

-    importc: "list_item_set_sel_text_color", dynlib: clarodll.}

-#*

-#  \brief Set the text background color of a selected item.

-#  This is currently only supported by the TreeView widget.

-# 

-#  \param item Target list item

-#  \param r Red component between 0.0 and 1.0

-#  \param g Green component between 0.0 and 1.0

-#  \param b Blue component between 0.0 and 1.0

-#  \param a Alpha component between 0.0 and 1.0 (reserved for future use,

-#          should be 1.0)

-# 

-

-proc list_item_set_sel_text_bgcolor*(item: ptr ListItem, r: cfloat, 

-                                     g: cfloat, b: cfloat, a: cfloat){.cdecl, 

-    importc: "list_item_set_sel_text_bgcolor", dynlib: clarodll.}

-#*

-#  \brief Set the font details of the specified item.

-# 

-#  \param item Target list item

-#  \param weight The weight of the font

-#  \param slant The slant of the font

-#  \param decoration Font decorations

-# 

-

-proc list_item_set_font_extra*(item: ptr ListItem, weight: cint, 

-                               slant: cint, decoration: cint){.cdecl, 

-    importc: "list_item_set_font_extra", dynlib: clarodll.}

-

-type 

-  Listbox* {.pure.} = object of ListWidget

-    selected*: ptr ListItem

-{.deprecated: [TListbox: Listbox].}

-

-# functions 

-#*

-#  \brief Creates a ListBox widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new ListBox widget object.

-# 

-

-proc newlistbox*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                 flags: cint): ptr Listbox{.

-    cdecl, importc: "listbox_widget_create", dynlib: clarodll.}

-#*

-#  \brief Insert a row at the specified position into a ListBox widget

-#  

-#  \param listbox A valid ListBox widget object.

-#  \param pos The index at which this item will be placed.

-#  \param text The text for the item.

-#  \return A new list item.

-# 

-

-proc listbox_insert_row*(listbox: ptr Listbox, pos: cint, 

-                         text: cstring): ptr ListItem{.

-    cdecl, importc: "listbox_insert_row", dynlib: clarodll.}

-#*

-#  \brief Append a row to a ListBox widget

-#  

-#  \param listbox A valid ListBox widget object.

-#  \param text The text for the item.

-#  \return A new list item.

-# 

-

-proc listbox_append_row*(listbox: ptr Listbox, text: cstring): ptr ListItem{.

-    cdecl, importc: "listbox_append_row", dynlib: clarodll.}

-#*

-#  \brief Move a row in a ListBox widget

-#  

-#  \param listbox A valid ListBox widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc listbox_move_row*(listbox: ptr Listbox, item: ptr ListItem, row: cint){.

-    cdecl, importc: "listbox_move_row", dynlib: clarodll.}

-#*

-#  \brief Remove a row from a ListBox widget

-#  

-#  \param listbox A valid ListBox widget object.

-#  \param item A valid list item

-# 

-

-proc listbox_remove_row*(listbox: ptr Listbox, item: ptr ListItem){.cdecl, 

-    importc: "listbox_remove_row", dynlib: clarodll.}

-#*

-#  \brief Returns the currently selected ListBox item

-#  

-#  \param obj A valid ListBox widget object.

-#  \return The currently selected ListBox item, or NULL if no item is selected.

-# 

-

-proc listbox_get_selected*(obj: ptr Listbox): ptr ListItem{.cdecl, 

-    importc: "listbox_get_selected", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a ListBox widget

-#  

-#  \param obj A valid ListBox widget object.

-#  \return Number of rows

-# 

-

-proc listbox_get_rows*(obj: ptr Listbox): cint{.cdecl, 

-    importc: "listbox_get_rows", dynlib: clarodll.}

-#*

-#  \brief Selects a row in a ListBox widget

-#  

-#  \param obj A valid ListBox widget object.

-#  \param item A valid list item

-# 

-

-proc listbox_select_item*(obj: ptr Listbox, item: ptr ListItem){.cdecl, 

-    importc: "listbox_select_item", dynlib: clarodll.}

-

-const 

-  cListViewTypeNone* = 0

-  cListViewTypeText* = 1

-  cListViewTypeCheckBox* = 2

-  cListViewTypeProgress* = 3

-

-# whole row checkboxes.. will we really need this? hmm.

-

-const 

-  cListViewRowCheckBoxes* = 1

-

-type 

-  Listview* {.pure.} = object of ListWidget

-    titles*: cstringArray

-    nativep*: pointer

-    selected*: ptr ListItem

-{.deprecated: [TListview: Listview].}

-

-# functions 

-#*

-#  \brief Creates a ListView widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \param columns The number of columns in the listview

-#  \param ... specifies the titles and types of each column. 

-#             ("Enable",cListViewTypeCheckBox,"Title",cListViewTypeText,...)

-#  \return A new ListView widget object.

-# 

-

-proc newlistview*(parent: ptr ClaroObj, bounds: ptr Bounds, columns: cint, 

-                  flags: cint): ptr Listview {.varargs, cdecl, 

-    importc: "listview_widget_create", dynlib: clarodll.}

-#*

-#  \brief Append a row to a ListView widget

-#  

-#  \param listview A valid ListView widget object.

-#  \param ... A list of values for each column

-#  \return A new list item.

-# 

-

-proc listview_append_row*(listview: ptr Listview): ptr ListItem{.varargs, 

-    cdecl, importc: "listview_append_row", dynlib: clarodll.}

-#*

-#  \brief Insert a row at the specified position into a ListView widget

-#  

-#  \param listview A valid ListView widget object.

-#  \param pos The index at which this item will be placed.

-#  \param ... A list of values for each column

-#  \return A new list item.

-# 

-

-proc listview_insert_row*(listview: ptr Listview, pos: cint): ptr ListItem{.

-    varargs, cdecl, importc: "listview_insert_row", dynlib: clarodll.}

-#*

-#  \brief Move a row in a ListView widget

-#  

-#  \param listview A valid ListView widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc listview_move_row*(listview: ptr Listview, item: ptr ListItem, 

-                        row: cint){.cdecl, importc: "listview_move_row", 

-                                    dynlib: clarodll.}

-#*

-#  \brief Remove a row from a ListView widget

-#  

-#  \param listview A valid ListView widget object.

-#  \param item A valid list item

-# 

-

-proc listview_remove_row*(listview: ptr Listview, item: ptr ListItem){.

-    cdecl, importc: "listview_remove_row", dynlib: clarodll.}

-#*

-#  \brief Returns the currently selected ListView item

-#  

-#  \param obj A valid ListView widget object.

-#  \return The currently selected ListView item, or NULL if no item is selected.

-# 

-

-proc listview_get_selected*(obj: ptr Listview): ptr ListItem{.cdecl, 

-    importc: "listview_get_selected", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a ListView widget

-#  

-#  \param obj A valid ListView widget object.

-#  \return Number of rows

-# 

-

-proc listview_get_rows*(obj: ptr Listview): cint{.cdecl, 

-    importc: "listview_get_rows", dynlib: clarodll.}

-#*

-#  \brief Selects a row in a ListView widget

-#  

-#  \param obj A valid ListView widget object.

-#  \param item A valid list item

-# 

-

-proc listview_select_item*(obj: ptr Listview, item: ptr ListItem){.cdecl, 

-    importc: "listview_select_item", dynlib: clarodll.}

-

-const 

-  cMenuPopupAtCursor* = 1

-

-type 

-  Menu* {.pure.} = object of ListWidget

-{.deprecated: [TMenu: Menu].}

-

-#*

-#  \brief Creates a Menu widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new Menu widget object.

-# 

-

-proc newmenu*(parent: ptr ClaroObj, flags: cint): ptr Menu {.cdecl, 

-    importc: "menu_widget_create", dynlib: clarodll.}

-#*

-#  \brief Append a row to a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \return A new list item.

-# 

-

-proc menu_append_item*(menu: ptr Menu, parent: ptr ListItem, 

-                       image: ptr Image, title: cstring): ptr ListItem{.

-    cdecl, importc: "menu_append_item", dynlib: clarodll.}

-#*

-#  \brief Insert a row into a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param pos The position at which to insert this item

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \return A new list item.

-# 

-

-proc menu_insert_item*(menu: ptr Menu, parent: ptr ListItem, pos: cint, 

-                       image: ptr Image, title: cstring): ptr ListItem{.

-    cdecl, importc: "menu_insert_item", dynlib: clarodll.}

-#*

-#  \brief Append a separator to a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \return A new list item.

-# 

-

-proc menu_append_separator*(menu: ptr Menu, 

-                            parent: ptr ListItem): ptr ListItem{.

-    cdecl, importc: "menu_append_separator", dynlib: clarodll.}

-#*

-#  \brief Insert a separator into a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param pos The position at which to insert this item

-#  \return A new list item.

-# 

-

-proc menu_insert_separator*(menu: ptr Menu, parent: ptr ListItem, 

-                            pos: cint): ptr ListItem{.cdecl, 

-    importc: "menu_insert_separator", dynlib: clarodll.}

-#*

-#  \brief Move a row in a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc menu_move_item*(menu: ptr Menu, item: ptr ListItem, row: cint){.

-    cdecl, importc: "menu_move_item", dynlib: clarodll.}

-#*

-#  \brief Remove a row from a Menu widget

-#  

-#  \param menu A valid Menu widget object.

-#  \param item A valid list item

-# 

-

-proc menu_remove_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, 

-    importc: "menu_remove_item", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a Menu widget

-#  

-#  \param obj A valid Menu widget object.

-#  \param parent Item whose children count to return, 

-#  or NULL for root item count.

-#  \return Number of rows

-# 

-

-proc menu_item_count*(obj: ptr Menu, parent: ptr ListItem): cint{.

-    cdecl, importc: "menu_item_count", dynlib: clarodll.}

-#*

-#  \brief Disables a menu item (no focus and greyed out)

-#  

-#  \param menu A valid Menu widget object.

-#  \param item A valid list item

-# 

-

-proc menu_disable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, 

-    importc: "menu_disable_item", dynlib: clarodll.}

-#*

-#  \brief Enables a menu item (allows focus and not greyed out)

-#  

-#  \param menu A valid Menu widget object.

-#  \param item A valid list item

-# 

-

-proc menu_enable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, 

-    importc: "menu_enable_item", dynlib: clarodll.}

-#*

-#  \brief Pops up the menu at the position specified

-#  

-#  \param menu A valid Menu widget object.

-#  \param x The X position

-#  \param y The Y position

-#  \param flags Flags

-# 

-

-proc menu_popup*(menu: ptr Menu, x: cint, y: cint, flags: cint){.cdecl, 

-    importc: "menu_popup", dynlib: clarodll.}

-#

-#   Menu modifiers

-# 

-

-const 

-  cModifierShift* = 1 shl 0

-  cModifierCommand* = 1 shl 1

-

-type 

-  Menubar* {.pure.} = object of ListWidget

-{.deprecated: [TMenubar: Menubar].}

-#*

-#  \brief Creates a MenuBar widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new MenuBar widget object.

-# 

-

-proc newmenubar*(parent: ptr ClaroObj, flags: cint): ptr Menubar {.cdecl, 

-    importc: "menubar_widget_create", dynlib: clarodll.}

-#*

-#  \brief Add a key binding to a menu items

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param item The item

-#  \param utf8_key The key to use, NOT NULL.

-#  \param modifier The modifier key, or 0.

-# 

-

-proc menubar_add_key_binding*(menubar: ptr Menubar, item: ptr ListItem, 

-                              utf8_key: cstring, modifier: cint){.cdecl, 

-    importc: "menubar_add_key_binding", dynlib: clarodll.}

-#*

-#  \brief Append a row to a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \return A new list item.

-# 

-

-proc menubar_append_item*(menubar: ptr Menubar, parent: ptr ListItem, 

-                          image: ptr Image, title: cstring): ptr ListItem{.

-    cdecl, importc: "menubar_append_item", dynlib: clarodll.}

-#*

-#  \brief Insert a row into a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param pos The position at which to insert this item

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \return A new list item.

-# 

-

-proc menubar_insert_item*(menubar: ptr Menubar, parent: ptr ListItem, 

-                          pos: cint, image: ptr Image, 

-                          title: cstring): ptr ListItem{.

-    cdecl, importc: "menubar_insert_item", dynlib: clarodll.}

-#*

-#  \brief Append a separator to a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \return A new list item.

-# 

-

-proc menubar_append_separator*(menubar: ptr Menubar, 

-                               parent: ptr ListItem): ptr ListItem{.

-    cdecl, importc: "menubar_append_separator", dynlib: clarodll.}

-#*

-#  \brief Insert a separator into a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param parent The item to place the new item under, or NULL for a root item.

-#  \param pos The position at which to insert this item

-#  \return A new list item.

-# 

-

-proc menubar_insert_separator*(menubar: ptr Menubar, parent: ptr ListItem, 

-                               pos: cint): ptr ListItem{.cdecl, 

-    importc: "menubar_insert_separator", dynlib: clarodll.}

-#*

-#  \brief Move a row in a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc menubar_move_item*(menubar: ptr Menubar, item: ptr ListItem, 

-                        row: cint){.cdecl, importc: "menubar_move_item", 

-                                    dynlib: clarodll.}

-#*

-#  \brief Remove a row from a MenuBar widget

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param item A valid list item

-# 

-

-proc menubar_remove_item*(menubar: ptr Menubar, item: ptr ListItem) {.

-    cdecl, importc: "menubar_remove_item", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a MenuBar widget

-#  

-#  \param obj A valid MenuBar widget object.

-#  \param parent Item whose children count to return, or NULL for root

-#         item count.

-#  \return Number of rows

-# 

-

-proc menubar_item_count*(obj: ptr Menubar, parent: ptr ListItem): cint{.

-    cdecl, importc: "menubar_item_count", dynlib: clarodll.}

-#*

-#  \brief Disables a menu item (no focus and greyed out)

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param item A valid list item

-# 

-

-proc menubar_disable_item*(menubar: ptr Menubar, item: ptr ListItem){.

-    cdecl, importc: "menubar_disable_item", dynlib: clarodll.}

-#*

-#  \brief Enables a menu item (allows focus and not greyed out)

-#  

-#  \param menubar A valid MenuBar widget object.

-#  \param item A valid list item

-# 

-

-proc menubar_enable_item*(menubar: ptr Menubar, item: ptr ListItem){.

-    cdecl, importc: "menubar_enable_item", dynlib: clarodll.}

-

-type 

-  Progress* {.pure.} = object of Widget

-

-  CProgressStyle* = enum 

-    cProgressLeftRight = 0x00000000, cProgressRightLeft = 0x00000001, 

-    cProgressTopBottom = 0x00000002, cProgressBottomTop = 0x00000004

-{.deprecated: [TProgress: Progress, TcProgressStyle: CProgressStyle].}

-

-#*

-#  \brief Creates a Progress widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Progress widget object.

-# 

-

-proc newprogress*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                  flags: cint): ptr Progress {.

-    cdecl, importc: "progress_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the value of a progress widget

-#  

-#  \param progress A valid progress widget object

-#  \param percentage Progress value

-# 

-

-proc progress_set_level*(progress: ptr Progress, percentage: cdouble){.cdecl, 

-    importc: "progress_set_level", dynlib: clarodll.}

-#*

-#  \brief Sets the orientation of a progress widget

-#  

-#  \param progress A valid progress widget object

-#  \param flags One of the cProgressStyle values

-# 

-

-proc progress_set_orientation*(progress: ptr Progress, flags: cint){.cdecl, 

-    importc: "progress_set_orientation", dynlib: clarodll.}

-

-type 

-  RadioGroup* {.pure.} = object of ClaroObj

-    buttons*: List

-    selected*: ptr ClaroObj

-    ndata*: pointer

-

-  RadioButton* {.pure.} = object of Widget

-    text*: array[0..256-1, char]

-    group*: ptr RadioGroup

-{.deprecated: [TRadioGroup: RadioGroup, TRadioButton: RadioButton].}

-

-#*

-#  \brief Creates a Radio Group widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new Radio Group widget object.

-# 

-

-proc newRadiogroup*(parent: ptr ClaroObj, flags: cint): ptr RadioGroup {.

-    cdecl, importc: "radiogroup_create", dynlib: clarodll.}

-#*

-#  \brief Creates a Radio Button widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param group A valid Radio Group widget object

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param label The label of the radio widget

-#  \param flags Widget flags.

-#  \return A new Radio Button widget object.

-# 

-

-proc newradiobutton*(parent: ptr ClaroObj, group: ptr RadioGroup, 

-                     bounds: ptr Bounds, label: cstring, 

-                     flags: cint): ptr RadioButton{.

-    cdecl, importc: "radiobutton_widget_create", dynlib: clarodll.}

-#*

-#  \brief Set the label of a Radio Button

-#  

-#  \param obj A valid Radio Button widget

-#  \param label The new label for the Radio Button

-# 

-

-proc radiobutton_set_text*(obj: ptr RadioButton, label: cstring){.cdecl, 

-    importc: "radiobutton_set_label", dynlib: clarodll.}

-#*

-#  \brief Set the group of a Radio Button

-#  

-#  \param rbutton A valid Radio Button widget

-#  \param group A valid Radio Group widget object

-# 

-

-proc radiobutton_set_group*(rbutton: ptr RadioButton, group: ptr RadioGroup){.

-    cdecl, importc: "radiobutton_set_group", dynlib: clarodll.}

-

-const 

-  CLARO_SCROLLBAR_MAXIMUM* = 256

-

-type 

-  Scrollbar* {.pure.} = object of Widget

-    min*: cint

-    max*: cint

-    pagesize*: cint

-{.deprecated: [TScrollbar: Scrollbar].}

-

-const 

-  cScrollbarHorizontal* = 0

-  cScrollbarVertical* = 1

-

-# functions 

-#*

-#  \brief Creates a ScrollBar widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new ScrollBar widget object.

-# 

-

-proc newscrollbar*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                   flags: cint): ptr Scrollbar{.

-    cdecl, importc: "scrollbar_widget_create", dynlib: clarodll.}

-#*

-#  \brief Returns the width that scrollbars should be on this platform

-#  

-#  \return Width of vertical scrollbars

-# 

-

-proc scrollbar_get_sys_width*(): cint{.cdecl, 

-                                       importc: "scrollbar_get_sys_width", 

-                                       dynlib: clarodll.}

-#*

-#  \brief Sets the range of a ScrollBar widget

-#  

-#  \param w A valid ScrollBar widget object

-#  \param min The minimum value

-#  \param max The maximum value

-# 

-

-proc scrollbar_set_range*(w: ptr Scrollbar, min: cint, max: cint){.cdecl, 

-    importc: "scrollbar_set_range", dynlib: clarodll.}

-#*

-#  \brief Sets the position of a ScrollBar widget

-#  

-#  \param w A valid ScrollBar widget object

-#  \param pos The new position

-# 

-

-proc scrollbar_set_pos*(w: ptr Scrollbar, pos: cint){.cdecl, 

-    importc: "scrollbar_set_pos", dynlib: clarodll.}

-#*

-#  \brief Gets the position of a ScrollBar widget

-#  

-#  \param w A valid ScrollBar widget object

-#  \return The current position

-# 

-

-proc scrollbar_get_pos*(w: ptr Scrollbar): cint{.cdecl, 

-    importc: "scrollbar_get_pos", dynlib: clarodll.}

-#*

-#  \brief Sets the page size of a ScrollBar widget

-# 

-#  \param w A valid ScrollBar widget object

-#  \param pagesize The size of a page (the number of units visible at one time)

-# 

-

-proc scrollbar_set_pagesize*(w: ptr Scrollbar, pagesize: cint){.cdecl, 

-    importc: "scrollbar_set_pagesize", dynlib: clarodll.}

-    

-type 

-  CSplitterChildren* = enum 

-    cSplitterFirst = 0, cSplitterSecond = 1

-  SplitterChild* {.pure.} = object 

-    flex*: cint

-    size*: cint

-    w*: ptr Widget

-

-  Splitter* {.pure.} = object of Widget

-    pair*: array[0..1, SplitterChild]

-{.deprecated: [TcSplitterChildren: CSplitterChildren, TSplitter: Splitter,

-              TSplitterChild: SplitterChild].}

-

-const 

-  cSplitterHorizontal* = 0

-  cSplitterVertical* = 1

-

-# functions 

-#*

-#  \brief Creates a Splitter widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Splitter widget object.

-# 

-

-proc newsplitter*(parent: ptr ClaroObj, bounds: ptr Bounds,

-                  flags: cint): ptr Splitter{.

-    cdecl, importc: "splitter_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the sizing information of a child

-#  

-#  \param splitter A valid splitter widget object

-#  \param child The child number, either cSplitterFirst or cSplitterSecond.

-#  \param flex 1 if this child should receive extra space as the splitter 

-#         expands, 0 if not

-#  \param size The size of this child

-# 

-

-proc splitter_set_info*(splitter: ptr Splitter, child: cint, flex: cint, 

-                        size: cint){.cdecl, importc: "splitter_set_info", 

-                                     dynlib: clarodll.}

-                                     

-type 

-  Statusbar* {.pure.} = object of Widget

-    text*: array[0..256 - 1, char]

-{.deprecated: [TStatusbar: Statusbar].}

-

-

-#*

-#  \brief Creates a StatusBar widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new StatusBar widget object.

-# 

-

-proc newstatusbar*(parent: ptr ClaroObj, flags: cint): ptr Statusbar {.cdecl, 

-    importc: "statusbar_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the text of a statusbar

-#  

-#  \param obj A valid StatusBar widget

-#  \param text The new text

-# 

-

-proc statusbar_set_text*(obj: ptr Statusbar, text: cstring){.cdecl, 

-    importc: "statusbar_set_text", dynlib: clarodll.}

-#*

-#  \brief obtains a stock image

-#  

-#  \param stock_id The string ID of the stock image, NOT NULL.

-#  \return The Image object.

-# 

-

-proc stock_get_image*(stock_id: cstring): ptr Image{.cdecl, 

-    importc: "stock_get_image", dynlib: clarodll.}

-#*

-#  \brief adds a stock id image

-#  

-#  \param stock_id The string ID of the stock image, NOT NULL.

-#  \param img The Image object to add.

-#  \return The Image object.

-# 

-

-proc stock_add_image*(stock_id: cstring, img: ptr Image){.cdecl, 

-    importc: "stock_add_image", dynlib: clarodll.}

-

-const 

-  CLARO_TEXTAREA_MAXIMUM = (1024 * 1024)

-

-type 

-  TextArea* {.pure.} = object of Widget

-    text*: array[0..CLARO_TEXTAREA_MAXIMUM - 1, char]

-{.deprecated: [TTextArea: TextArea].}

-

-

-#*

-#  \brief Creates a TextArea widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new TextArea widget object.

-# 

-

-proc newtextarea*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                  flags: cint): ptr TextArea{.

-    cdecl, importc: "textarea_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the text of a textarea

-#  

-#  \param obj A valid TextArea widget

-#  \param text The new text

-# 

-

-proc textarea_set_text*(obj: ptr TextArea, text: cstring){.cdecl, 

-    importc: "textarea_set_text", dynlib: clarodll.}

-#*

-#  \brief Retrieve the text of a textarea

-#  

-#  \param obj A valid TextArea widget

-#  \return Pointer to an internal reference of the text. Should not be changed.

-# 

-

-proc textarea_get_text*(obj: ptr TextArea): cstring{.cdecl, 

-    importc: "textarea_get_text", dynlib: clarodll.}

-

-const 

-  CLARO_TEXTBOX_MAXIMUM = 8192

-

-type 

-  TextBox* {.pure.} = object of Widget

-    text*: array[0..CLARO_TEXTBOX_MAXIMUM-1, char]

-{.deprecated: [TTextBox: TextBox].}

-

-const 

-  cTextBoxTypePassword* = 1

-

-# functions 

-#*

-#  \brief Creates a TextBox widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new TextBox widget object.

-# 

-

-proc newtextbox*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                 flags: cint): ptr TextBox{.

-    cdecl, importc: "textbox_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the text of a textbox

-#  

-#  \param obj A valid TextBox widget

-#  \param text The new text

-# 

-

-proc textbox_set_text*(obj: ptr TextBox, text: cstring){.cdecl, 

-    importc: "textbox_set_text", dynlib: clarodll.}

-#*

-#  \brief Retrieve the text of a textbox

-#  

-#  \param obj A valid TextBox widget

-#  \return Pointer to an internal reference of the text. Should not be changed.

-# 

-

-proc textbox_get_text*(obj: ptr TextBox): cstring{.cdecl, 

-    importc: "textbox_get_text", dynlib: clarodll.}

-#*

-#  \brief Retrieve the cursor position inside a textbox

-#  

-#  \param obj A valid TextBox widget

-#  \return Cursor position inside TextBox

-# 

-

-proc textbox_get_pos*(obj: ptr TextBox): cint{.cdecl, 

-    importc: "textbox_get_pos", dynlib: clarodll.}

-#*

-#  \brief Sets the cursor position inside a textbox

-#  

-#  \param obj A valid TextBox widget

-#  \param pos New cursor position inside TextBox

-# 

-

-proc textbox_set_pos*(obj: ptr TextBox, pos: cint){.cdecl, 

-    importc: "textbox_set_pos", dynlib: clarodll.}

-

-const 

-  cToolbarShowText* = 1

-  cToolbarShowImages* = 2

-  cToolbarShowBoth* = 3

-  cToolbarAutoSizeButtons* = 4

-

-type 

-  Toolbar* {.pure.} = object of ListWidget

-{.deprecated: [TToolbar: Toolbar].}

-#*

-#  \brief Creates a ToolBar widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param flags Widget flags.

-#  \return A new ToolBar widget object.

-# 

-

-proc newtoolbar*(parent: ptr ClaroObj, flags: cint): ptr Toolbar{.cdecl, 

-    importc: "toolbar_widget_create", dynlib: clarodll.}

-#*

-#  \brief Append a row to a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \param tooltip A string tooltip, or NULL.

-#  \return A new list item.

-# 

-

-proc toolbar_append_icon*(toolbar: ptr Toolbar, image: ptr Image, 

-                          title: cstring, tooltip: cstring): ptr ListItem{.

-    cdecl, importc: "toolbar_append_icon", dynlib: clarodll.}

-#*

-#  \brief Insert a row into a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param pos The position at which to insert this item

-#  \param image An image object, or NULL.

-#  \param title A string title, or NULL.

-#  \param tooltip A string tooltip, or NULL.

-#  \return A new list item.

-# 

-

-proc toolbar_insert_icon*(toolbar: ptr Toolbar, pos: cint, 

-                          image: ptr Image, title: cstring, 

-                          tooltip: cstring): ptr ListItem{.

-    cdecl, importc: "toolbar_insert_icon", dynlib: clarodll.}

-#*

-#  \brief Append a separator to a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \return A new list item.

-# 

-

-proc toolbar_append_separator*(toolbar: ptr Toolbar): ptr ListItem{.cdecl, 

-    importc: "toolbar_append_separator", dynlib: clarodll.}

-#*

-#  \brief Insert a separator into a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param pos The position at which to insert this item

-#  \return A new list item.

-# 

-

-proc toolbar_insert_separator*(toolbar: ptr Toolbar, 

-                               pos: cint): ptr ListItem {.

-    cdecl, importc: "toolbar_insert_separator", dynlib: clarodll.}

-#*

-#  \brief Assign a menu widget to an item.

-# 

-#  This will show a small down arrow next to the item

-#  that will open this menu.

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param item Toolbar item the menu is for.

-#  \param menu Menu widget object, or NULL to remove a menu.

-# 

-

-proc toolbar_set_item_menu*(toolbar: ptr Toolbar, item: ptr ListItem, 

-                            menu: ptr Menu){.cdecl, 

-    importc: "toolbar_set_item_menu", dynlib: clarodll.}

-#*

-#  \brief Move a row in a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc toolbar_move_icon*(toolbar: ptr Toolbar, item: ptr ListItem, 

-                        row: cint){.cdecl, importc: "toolbar_move_icon", 

-                                    dynlib: clarodll.}

-#*

-#  \brief Remove a row from a ToolBar widget

-#  

-#  \param toolbar A valid ToolBar widget object.

-#  \param item A valid list item

-# 

-

-proc toolbar_remove_icon*(toolbar: ptr Toolbar, item: ptr ListItem){.

-    cdecl, importc: "toolbar_remove_icon", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a ToolBar widget

-#  

-#  \param obj A valid ToolBar widget object.

-#  \return Number of rows

-# 

-

-proc toolbar_item_count*(obj: ptr Toolbar): cint{.cdecl, 

-    importc: "toolbar_item_count", dynlib: clarodll.}

-#*

-#  \brief TreeView widget

-# 

-

-type 

-  Treeview* {.pure.} = object of ListWidget

-    selected*: ptr ListItem

-{.deprecated: [TTreeview: Treeview].}

-

-# functions 

-#*

-#  \brief Creates a TreeView widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new TreeView widget object.

-# 

-

-proc newtreeview*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                  flags: cint): ptr Treeview{.

-    cdecl, importc: "treeview_widget_create", dynlib: clarodll.}

-#*

-#  \brief Append a row to a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param parent The item under which to place the new item, or NULL for a root node.

-#  \param image An image to go to the left of the item, or NULL for no image.

-#  \param title The text for the item.

-#  \return A new list item.

-# 

-

-proc treeview_append_row*(treeview: ptr Treeview, parent: ptr ListItem, 

-                          image: ptr Image, title: cstring): ptr ListItem{.

-    cdecl, importc: "treeview_append_row", dynlib: clarodll.}

-#*

-#  \brief Insert a row at the specified position into a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param parent The item under which to place the new item, or NULL for a root node.

-#  \param pos The index at which this item will be placed.

-#  \param image An image to go to the left of the item, or NULL for no image.

-#  \param title The text for the item.

-#  \return A new list item.

-# 

-

-proc treeview_insert_row*(treeview: ptr Treeview, parent: ptr ListItem, 

-                          pos: cint, image: ptr Image, 

-                          title: cstring): ptr ListItem{.

-    cdecl, importc: "treeview_insert_row", dynlib: clarodll.}

-#*

-#  \brief Move a row in a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param item A valid list item

-#  \param row New position to place this item

-# 

-

-proc treeview_move_row*(treeview: ptr Treeview, item: ptr ListItem, 

-                        row: cint){.cdecl, importc: "treeview_move_row", 

-                                    dynlib: clarodll.}

-#*

-#  \brief Remove a row from a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param item A valid list item

-# 

-

-proc treeview_remove_row*(treeview: ptr Treeview, item: ptr ListItem){.

-    cdecl, importc: "treeview_remove_row", dynlib: clarodll.}

-#*

-#  \brief Expand a row in a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param item A valid list item

-# 

-

-proc treeview_expand*(treeview: ptr Treeview, item: ptr ListItem){.cdecl, 

-    importc: "treeview_expand", dynlib: clarodll.}

-#*

-#  \brief Collapse a row in a TreeView

-#  

-#  \param treeview A valid TreeView widget object.

-#  \param item A valid list item

-# 

-

-proc treeview_collapse*(treeview: ptr Treeview, item: ptr ListItem){.cdecl, 

-    importc: "treeview_collapse", dynlib: clarodll.}

-#*

-#  \brief Returns the currently selected TreeView item

-#  

-#  \param obj A valid TreeView widget object.

-#  \return The currently selected TreeView item, or NULL if no item is selected.

-# 

-

-proc treeview_get_selected*(obj: ptr Treeview): ptr ListItem{.cdecl, 

-    importc: "treeview_get_selected", dynlib: clarodll.}

-#*

-#  \brief Returns the number of rows in a TreeView

-#  

-#  \param obj A valid TreeView widget object.

-#  \param parent Return the number of children of this item, or the number of

-#                root items if NULL

-#  \return Number of rows

-# 

-

-proc treeview_get_rows*(obj: ptr Treeview, parent: ptr ListItem): cint{.

-    cdecl, importc: "treeview_get_rows", dynlib: clarodll.}

-#*

-#  \brief Selects a row in a TreeView

-#  

-#  \param obj A valid TreeView widget object.

-#  \param item A valid list item

-# 

-

-proc treeview_select_item*(obj: ptr Treeview, item: ptr ListItem){.cdecl, 

-    importc: "treeview_select_item", dynlib: clarodll.}

-

-const 

-  cWindowModalDialog* = 1

-  cWindowCenterParent* = 2

-  cWindowNoResizing* = 4

-

-type 

-  Window* {.pure.} = object of Widget

-    title*: array[0..512 - 1, char]

-    icon*: ptr Image

-    menubar*: ptr Widget

-    workspace*: ptr Widget

-    exsp_tools*: cint

-    exsp_status*: cint

-    exsp_init*: cint

-{.deprecated: [TWindow: Window].}

-

-const 

-  cWindowFixedSize* = 1

-

-# functions 

-#*

-#  \brief Creates a Window widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Window widget object.

-# 

-

-proc newwindow*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                flags: cint): ptr Window {.

-    cdecl, importc: "window_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets a Window's title

-#  

-#  \param w A valid Window widget object

-#  \param title The new title for the window

-# 

-

-proc window_set_title*(w: ptr Window, title: cstring){.cdecl, 

-    importc: "window_set_title", dynlib: clarodll.}

-#*

-#  \brief Makes a window visible

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_show*(w: ptr Window){.cdecl, importc: "window_show", 

-                                     dynlib: clarodll.}

-#*

-#  \brief Makes a window invisible

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_hide*(w: ptr Window){.cdecl, importc: "window_hide", 

-                                     dynlib: clarodll.}

-#*

-#  \brief Gives focus to a window

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_focus*(w: ptr Window){.cdecl, importc: "window_focus", 

-                                      dynlib: clarodll.}

-#*

-#  \brief Maximises a window

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_maximize*(w: ptr Window){.cdecl, importc: "window_maximise", 

-    dynlib: clarodll.}

-#*

-#  \brief Minimises a window

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_minimize*(w: ptr Window){.cdecl, importc: "window_minimise", 

-    dynlib: clarodll.}

-#*

-#  \brief Restores a window

-#  

-#  \param w A valid Window widget object

-# 

-

-proc window_restore*(w: ptr Window){.cdecl, importc: "window_restore", 

-                                        dynlib: clarodll.}

-#*

-#  \brief Sets a window's icon

-#  

-#  \param w A valid Window widget object

-#  \param icon A valid Image object

-# 

-

-proc window_set_icon*(w: ptr Window, icon: ptr Image){.cdecl, 

-    importc: "window_set_icon", dynlib: clarodll.}

-

-const 

-  cWorkspaceTileHorizontally* = 0

-  cWorkspaceTileVertically* = 1

-

-type 

-  Workspace*{.pure.} = object of Widget

-

-  WorkspaceWindow*{.pure.} = object of Widget

-    icon*: ptr Image

-    title*: array[0..512 - 1, char]

-    workspace*: ptr Workspace

-{.deprecated: [TWorkspace: Workspace, TWorkspaceWindow: WorkspaceWindow].}

-

-# functions (workspace) 

-#*

-#  \brief Creates a Workspace widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Workspace widget object.

-# 

-

-proc newworkspace*(parent: ptr ClaroObj, bounds: ptr Bounds, 

-                   flags: cint): ptr Workspace{.

-    cdecl, importc: "workspace_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the active (visible) workspace child

-#  

-#  \param workspace A valid workspace widget

-#  \param child A valid workspace window widget

-# 

-

-proc workspace_set_active*(workspace: ptr Workspace, child: ptr ClaroObj){.

-    cdecl, importc: "workspace_set_active", dynlib: clarodll.}

-#*

-#  \brief Returns the active (visible) workspace child

-#  

-#  \param workspace A valid workspace widget

-#  \return The active workspace window widget

-# 

-

-proc workspace_get_active*(workspace: ptr Workspace): ptr Workspace{.cdecl, 

-    importc: "workspace_get_active", dynlib: clarodll.}

-#*

-#  \brief Cascades all workspace windows

-#  

-#  \param workspace A valid workspace widget

-# 

-

-proc workspace_cascade*(workspace: ptr Workspace){.cdecl, 

-    importc: "workspace_cascade", dynlib: clarodll.}

-#*

-#  \brief Tiles all workspace windows

-#  

-#  \param workspace A valid workspace widget

-#  \param dir The direction to tile child widgets

-# 

-

-proc workspace_tile*(workspace: ptr Workspace, dir: cint){.cdecl, 

-    importc: "workspace_tile", dynlib: clarodll.}

-# functions (workspace_window) 

-#*

-#  \brief Creates a Workspace widget

-#  

-#  \param parent The parent widget of this widget, NOT NULL.

-#  \param bounds The initial bounds of this widget, or NO_BOUNDS.

-#  \param flags Widget flags.

-#  \return A new Workspace widget object.

-# 

-

-proc newWorkspaceWindow*(parent: ptr ClaroObj, 

-                         bounds: ptr Bounds, 

-                         flags: cint): ptr WorkspaceWindow{.

-    cdecl, importc: "workspace_window_widget_create", dynlib: clarodll.}

-#*

-#  \brief Sets the title of a Workspace Window widget

-#  

-#  \param window A valid Workspace Window widget

-#  \param title The new title for the widget

-# 

-

-proc workspace_window_set_title*(window: ptr WorkspaceWindow, 

-                                 title: cstring){.cdecl, 

-    importc: "workspace_window_set_title", dynlib: clarodll.}

-#*

-#  \brief Makes a Workspace Window widget visible

-#  

-#  \param window A valid Workspace Window widget

-# 

-

-proc workspace_window_show*(window: ptr WorkspaceWindow){.cdecl, 

-    importc: "workspace_window_show", dynlib: clarodll.}

-#*

-#  \brief Makes a Workspace Window widget invisible

-#  

-#  \param window A valid Workspace Window widget

-# 

-

-proc workspace_window_hide*(window: ptr WorkspaceWindow){.cdecl, 

-    importc: "workspace_window_hide", dynlib: clarodll.}

-#*

-#  \brief Restores a Workspace Window widget

-#  

-#  \param window A valid Workspace Window widget

-# 

-

-proc workspace_window_restore*(window: ptr WorkspaceWindow){.cdecl, 

-    importc: "workspace_window_restore", dynlib: clarodll.}

-# American spelling 

-

-#*

-#  \brief Minimises a Workspace Window widget

-#  

-#  \param window A valid Workspace Window widget

-# 

-

-proc workspace_window_minimize*(window: ptr WorkspaceWindow){.cdecl, 

-    importc: "workspace_window_minimise", dynlib: clarodll.}

-#*

-#  \brief Maxmimises a Workspace Window widget

-#  

-#  \param window A valid Workspace Window widget

-# 

-

-proc workspace_window_maximize*(window: ptr WorkspaceWindow){.cdecl, 

-    importc: "workspace_window_maximise", dynlib: clarodll.}

-#*

-#  \brief Sets the icon of a Workspace Window widget

-#  

-#  \param window A valid Workspace Window widget

-#  \param icon A valid Image object.

-# 

-

-proc workspace_window_set_icon*(w: ptr WorkspaceWindow, icon: ptr Image){.

-    cdecl, importc: "workspace_window_set_icon", dynlib: clarodll.}

-    

-claro_base_init()

-claro_graphics_init()

-

-when not defined(testing) and isMainModule:

-  var w = newWindow(nil, newBounds(100, 100, 230, 230), 0)

-  window_set_title(w, "Hello, World!")

-

-  var t = newTextbox(w, new_bounds(10, 10, 210, -1), 0)

-  widget_set_notify(t, cNotifyKey)

-  textbox_set_text(t, "Yeehaw!")

-

-  var b = newButton(w, new_bounds(40, 45, 150, -1), 0, "Push my button!")

-

-  proc push_my_button(obj: ptr ClaroObj, event: ptr Event) {.cdecl.} =

-    textbox_set_text(t, "You pushed my button!")

-    var button = cast[ptr Button](obj)

-    button_set_text(button, "Ouch!")

-

-  object_addhandler(b, "pushed", push_my_button)

-

-  window_show(w)

-  window_focus(w)

-

-  claro_loop()

-

diff --git a/lib/wrappers/expat.nim b/lib/wrappers/expat.nim
deleted file mode 100644
index e1897e2b4..000000000
--- a/lib/wrappers/expat.nim
+++ /dev/null
@@ -1,899 +0,0 @@
-# Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-#   See the file COPYING for copying permission.
-#
-
-when not defined(expatDll): 
-  when defined(windows): 
-    const 
-      expatDll = "expat.dll"
-  elif defined(macosx): 
-    const 
-      expatDll = "libexpat.dylib"
-  else: 
-    const 
-      expatDll = "libexpat.so(.1|)"
-type 
-  ParserStruct{.pure, final.} = object 
-  
-  PParser* = ptr ParserStruct
-
-# The XML_Status enum gives the possible return values for several
-#   API functions.  The preprocessor #defines are included so this
-#   stanza can be added to code that still needs to support older
-#   versions of Expat 1.95.x:
-#
-#   #ifndef XML_STATUS_OK
-#   #define XML_STATUS_OK    1
-#   #define XML_STATUS_ERROR 0
-#   #endif
-#
-#   Otherwise, the #define hackery is quite ugly and would have been
-#   dropped.
-#
-{.deprecated: [TParserStruct: ParserStruct].}
-
-type 
-  Status*{.size: sizeof(cint).} = enum 
-    STATUS_ERROR = 0, STATUS_OK = 1, STATUS_SUSPENDED = 2
-  Error*{.size: sizeof(cint).} = enum 
-    ERROR_NONE, ERROR_NO_MEMORY, ERROR_SYNTAX, ERROR_NO_ELEMENTS, 
-    ERROR_INVALID_TOKEN, ERROR_UNCLOSED_TOKEN, ERROR_PARTIAL_CHAR, 
-    ERROR_TAG_MISMATCH, ERROR_DUPLICATE_ATTRIBUTE,
-    ERROR_JUNK_AFTER_DOC_ELEMENT, 
-    ERROR_PARAM_ENTITY_REF, ERROR_UNDEFINED_ENTITY, ERROR_RECURSIVE_ENTITY_REF, 
-    ERROR_ASYNC_ENTITY, ERROR_BAD_CHAR_REF, ERROR_BINARY_ENTITY_REF, 
-    ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, ERROR_MISPLACED_XML_PI, 
-    ERROR_UNKNOWN_ENCODING, ERROR_INCORRECT_ENCODING, 
-    ERROR_UNCLOSED_CDATA_SECTION, ERROR_EXTERNAL_ENTITY_HANDLING, 
-    ERROR_NOT_STANDALONE, ERROR_UNEXPECTED_STATE, ERROR_ENTITY_DECLARED_IN_PE, 
-    ERROR_FEATURE_REQUIRES_XML_DTD, ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,  
-    ERROR_UNBOUND_PREFIX,     
-    ERROR_UNDECLARING_PREFIX, ERROR_INCOMPLETE_PE, ERROR_XML_DECL, 
-    ERROR_TEXT_DECL, ERROR_PUBLICID, ERROR_SUSPENDED, ERROR_NOT_SUSPENDED, 
-    ERROR_ABORTED, ERROR_FINISHED, ERROR_SUSPEND_PE, 
-    ERROR_RESERVED_PREFIX_XML, ERROR_RESERVED_PREFIX_XMLNS, 
-    ERROR_RESERVED_NAMESPACE_URI
-  ContentType*{.size: sizeof(cint).} = enum 
-    CTYPE_EMPTY = 1, CTYPE_ANY, CTYPE_MIXED, CTYPE_NAME, CTYPE_CHOICE, CTYPE_SEQ
-  ContentQuant*{.size: sizeof(cint).} = enum 
-    CQUANT_NONE, CQUANT_OPT, CQUANT_REP, CQUANT_PLUS
-{.deprecated: [TStatus: Status, TError: Error, TContent_Type: ContentType,
-              TContent_Quant: ContentQuant].}
-
-# If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
-#   XML_CQUANT_NONE, and the other fields will be zero or NULL.
-#   If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
-#   numchildren will contain number of elements that may be mixed in
-#   and children point to an array of XML_Content cells that will be
-#   all of XML_CTYPE_NAME type with no quantification.
-#
-#   If type == XML_CTYPE_NAME, then the name points to the name, and
-#   the numchildren field will be zero and children will be NULL. The
-#   quant fields indicates any quantifiers placed on the name.
-#
-#   CHOICE and SEQ will have name NULL, the number of children in
-#   numchildren and children will point, recursively, to an array
-#   of XML_Content cells.
-#
-#   The EMPTY, ANY, and MIXED types will only occur at top level.
-#
-
-type 
-  Content*{.pure, final.} = object 
-    typ*: ContentType
-    quant*: ContentQuant
-    name*: cstring
-    numchildren*: cint
-    children*: ptr Content
-{.deprecated: [TContent: Content].}
-
-# This is called for an element declaration. See above for
-#   description of the model argument. It's the caller's responsibility
-#   to free model when finished with it.
-#
-
-type 
-  ElementDeclHandler* = proc (userData: pointer, name: cstring, 
-                               model: ptr Content){.cdecl.}
-{.deprecated: [TElementDeclHandler: ElementDeclHandler].}
-
-proc setElementDeclHandler*(parser: PParser, eldecl: ElementDeclHandler){.
-    cdecl, importc: "XML_SetElementDeclHandler", dynlib: expatDll.}
-# The Attlist declaration handler is called for *each* attribute. So
-#   a single Attlist declaration with multiple attributes declared will
-#   generate multiple calls to this handler. The "default" parameter
-#   may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
-#   keyword. The "isrequired" parameter will be true and the default
-#   value will be NULL in the case of "#REQUIRED". If "isrequired" is
-#   true and default is non-NULL, then this is a "#FIXED" default.
-#
-
-type 
-  AttlistDeclHandler* = proc (userData: pointer, elname: cstring, 
-                               attname: cstring, attType: cstring, 
-                               dflt: cstring, isrequired: cint){.cdecl.}
-{.deprecated: [TAttlistDeclHandler: AttlistDeclHandler].}
-
-proc setAttlistDeclHandler*(parser: PParser, attdecl: AttlistDeclHandler){.
-    cdecl, importc: "XML_SetAttlistDeclHandler", dynlib: expatDll.}
-# The XML declaration handler is called for *both* XML declarations
-#   and text declarations. The way to distinguish is that the version
-#   parameter will be NULL for text declarations. The encoding
-#   parameter may be NULL for XML declarations. The standalone
-#   parameter will be -1, 0, or 1 indicating respectively that there
-#   was no standalone parameter in the declaration, that it was given
-#   as no, or that it was given as yes.
-#
-
-type 
-  XmlDeclHandler* = proc (userData: pointer, version: cstring, 
-                           encoding: cstring, standalone: cint){.cdecl.}
-{.deprecated: [TXmlDeclHandler: XmlDeclHandler].}
-
-proc setXmlDeclHandler*(parser: PParser, xmldecl: XmlDeclHandler){.cdecl, 
-    importc: "XML_SetXmlDeclHandler", dynlib: expatDll.}
-type 
-  Memory_Handling_Suite*{.pure, final.} = object 
-    mallocFcn*: proc (size: int): pointer{.cdecl.}
-    reallocFcn*: proc (p: pointer, size: int): pointer{.cdecl.}
-    freeFcn*: proc (p: pointer){.cdecl.}
-{.deprecated: [TMemory_Handling_Suite: MemoryHandlingSuite].}
-
-# Constructs a new parser; encoding is the encoding specified by the
-#   external protocol or NULL if there is none specified.
-#
-
-proc parserCreate*(encoding: cstring): PParser{.cdecl, 
-    importc: "XML_ParserCreate", dynlib: expatDll.}
-# Constructs a new parser and namespace processor.  Element type
-#   names and attribute names that belong to a namespace will be
-#   expanded; unprefixed attribute names are never expanded; unprefixed
-#   element type names are expanded only if there is a default
-#   namespace. The expanded name is the concatenation of the namespace
-#   URI, the namespace separator character, and the local part of the
-#   name.  If the namespace separator is '\0' then the namespace URI
-#   and the local part will be concatenated without any separator.
-#   It is a programming error to use the separator '\0' with namespace
-#   triplets (see XML_SetReturnNSTriplet).
-#
-
-proc parserCreateNS*(encoding: cstring, namespaceSeparator: char): PParser{.
-    cdecl, importc: "XML_ParserCreateNS", dynlib: expatDll.}
-# Constructs a new parser using the memory management suite referred to
-#   by memsuite. If memsuite is NULL, then use the standard library memory
-#   suite. If namespaceSeparator is non-NULL it creates a parser with
-#   namespace processing as described above. The character pointed at
-#   will serve as the namespace separator.
-#
-#   All further memory operations used for the created parser will come from
-#   the given suite.
-#
-
-proc parserCreateMM*(encoding: cstring, memsuite: ptr TMemoryHandlingSuite, 
-                      namespaceSeparator: cstring): PParser{.cdecl, 
-    importc: "XML_ParserCreate_MM", dynlib: expatDll.}
-# Prepare a parser object to be re-used.  This is particularly
-#   valuable when memory allocation overhead is disproportionatly high,
-#   such as when a large number of small documnents need to be parsed.
-#   All handlers are cleared from the parser, except for the
-#   unknownEncodingHandler. The parser's external state is re-initialized
-#   except for the values of ns and ns_triplets.
-#
-#   Added in Expat 1.95.3.
-#
-
-proc parserReset*(parser: PParser, encoding: cstring): bool{.cdecl, 
-    importc: "XML_ParserReset", dynlib: expatDll.}
-# atts is array of name/value pairs, terminated by 0;
-#   names and values are 0 terminated.
-#
-
-type 
-  StartElementHandler* = proc (userData: pointer, name: cstring, 
-                                atts: cstringArray){.cdecl.}
-  EndElementHandler* = proc (userData: pointer, name: cstring){.cdecl.}
-{.deprecated: [TStartElementHandler: StartElementHandler,
-              TEndElementHandler: EndElementHandler].}
-# s is not 0 terminated. 
-
-type 
-  CharacterDataHandler* = proc (userData: pointer, s: cstring, len: cint){.
-      cdecl.}
-{.deprecated: [TCharacterDataHandler: CharacterDataHandler].}
-# target and data are 0 terminated 
-
-type 
-  ProcessingInstructionHandler* = proc (userData: pointer, target: cstring, 
-      data: cstring){.cdecl.}
-{.deprecated: [TProcessingInstructionHandler: ProcessingInstructionHandler].}
-
-# data is 0 terminated 
-
-type 
-  CommentHandler* = proc (userData: pointer, data: cstring){.cdecl.}
-  StartCdataSectionHandler* = proc (userData: pointer){.cdecl.}
-  EndCdataSectionHandler* = proc (userData: pointer){.cdecl.}
-{.deprecated: [TCommentHandler: CommentHandler,
-              TStartCdataSectionHandler: StartCdataSectionHandler,
-              TEndCdataSectionHandler: EndCdataSectionHandler].}
-# This is called for any characters in the XML document for which
-#   there is no applicable handler.  This includes both characters that
-#   are part of markup which is of a kind that is not reported
-#   (comments, markup declarations), or characters that are part of a
-#   construct which could be reported but for which no handler has been
-#   supplied. The characters are passed exactly as they were in the XML
-#   document except that they will be encoded in UTF-8 or UTF-16.
-#   Line boundaries are not normalized. Note that a byte order mark
-#   character is not passed to the default handler. There are no
-#   guarantees about how characters are divided between calls to the
-#   default handler: for example, a comment might be split between
-#   multiple calls.
-#
-
-type 
-  DefaultHandler* = proc (userData: pointer, s: cstring, len: cint){.cdecl.}
-{.deprecated: [TDefaultHandler: DefaultHandler].}
-# This is called for the start of the DOCTYPE declaration, before
-#   any DTD or internal subset is parsed.
-#
-
-type 
-  StartDoctypeDeclHandler* = proc (userData: pointer, doctypeName: cstring, 
-                                    sysid: cstring, pubid: cstring, 
-                                    hasInternalSubset: cint){.cdecl.}
-{.deprecated: [TStartDoctypeDeclHandler: StartDoctypeDeclHandler].}
-
-# This is called for the start of the DOCTYPE declaration when the
-#   closing > is encountered, but after processing any external
-#   subset.
-#
-
-type 
-  EndDoctypeDeclHandler* = proc (userData: pointer){.cdecl.}
-{.deprecated: [TEndDoctypeDeclHandler: EndDoctypeDeclHandler].}
-
-# This is called for entity declarations. The is_parameter_entity
-#   argument will be non-zero if the entity is a parameter entity, zero
-#   otherwise.
-#
-#   For internal entities (<!ENTITY foo "bar">), value will
-#   be non-NULL and systemId, publicID, and notationName will be NULL.
-#   The value string is NOT nul-terminated; the length is provided in
-#   the value_length argument. Since it is legal to have zero-length
-#   values, do not use this argument to test for internal entities.
-#
-#   For external entities, value will be NULL and systemId will be
-#   non-NULL. The publicId argument will be NULL unless a public
-#   identifier was provided. The notationName argument will have a
-#   non-NULL value only for unparsed entity declarations.
-#
-#   Note that is_parameter_entity can't be changed to XML_Bool, since
-#   that would break binary compatibility.
-#
-
-type 
-  EntityDeclHandler* = proc (userData: pointer, entityName: cstring, 
-                              isParameterEntity: cint, value: cstring, 
-                              valueLength: cint, base: cstring, 
-                              systemId: cstring, publicId: cstring, 
-                              notationName: cstring){.cdecl.}
-{.deprecated: [TEntityDeclHandler: EntityDeclHandler].}
-
-proc setEntityDeclHandler*(parser: PParser, handler: EntityDeclHandler){.cdecl, 
-    importc: "XML_SetEntityDeclHandler", dynlib: expatDll.}
-# OBSOLETE -- OBSOLETE -- OBSOLETE
-#   This handler has been superceded by the EntityDeclHandler above.
-#   It is provided here for backward compatibility.
-#
-#   This is called for a declaration of an unparsed (NDATA) entity.
-#   The base argument is whatever was set by XML_SetBase. The
-#   entityName, systemId and notationName arguments will never be
-#   NULL. The other arguments may be.
-#
-
-type 
-  UnparsedEntityDeclHandler* = proc (userData: pointer, entityName: cstring, 
-                                      base: cstring, systemId: cstring, 
-                                      publicId, notationName: cstring){.
-      cdecl.}
-{.deprecated: [TUnparsedEntityDeclHandler: UnparsedEntityDeclHandler].}
-
-# This is called for a declaration of notation.  The base argument is
-#   whatever was set by XML_SetBase. The notationName will never be
-#   NULL.  The other arguments can be.
-#
-
-type 
-  NotationDeclHandler* = proc (userData: pointer, notationName: cstring, 
-                                base: cstring, systemId: cstring, 
-                                publicId: cstring){.cdecl.}
-{.deprecated: [TNotationDeclHandler: NotationDeclHandler].}
-
-# When namespace processing is enabled, these are called once for
-#   each namespace declaration. The call to the start and end element
-#   handlers occur between the calls to the start and end namespace
-#   declaration handlers. For an xmlns attribute, prefix will be
-#   NULL.  For an xmlns="" attribute, uri will be NULL.
-#
-
-type 
-  StartNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring, 
-                                      uri: cstring){.cdecl.}
-  EndNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring){.cdecl.}
-{.deprecated: [TStartNamespaceDeclHandler: StartNamespaceDeclHandler,
-              TEndNamespaceDeclHandler: EndNamespaceDeclHandler].}
-# This is called if the document is not standalone, that is, it has an
-#   external subset or a reference to a parameter entity, but does not
-#   have standalone="yes". If this handler returns XML_STATUS_ERROR,
-#   then processing will not continue, and the parser will return a
-#   XML_ERROR_NOT_STANDALONE error.
-#   If parameter entity parsing is enabled, then in addition to the
-#   conditions above this handler will only be called if the referenced
-#   entity was actually read.
-#
-
-type 
-  NotStandaloneHandler* = proc (userData: pointer): cint{.cdecl.}
-{.deprecated: [TNotStandaloneHandler: NotStandaloneHandler].}
-
-# This is called for a reference to an external parsed general
-#   entity.  The referenced entity is not automatically parsed.  The
-#   application can parse it immediately or later using
-#   XML_ExternalEntityParserCreate.
-#
-#   The parser argument is the parser parsing the entity containing the
-#   reference; it can be passed as the parser argument to
-#   XML_ExternalEntityParserCreate.  The systemId argument is the
-#   system identifier as specified in the entity declaration; it will
-#   not be NULL.
-#
-#   The base argument is the system identifier that should be used as
-#   the base for resolving systemId if systemId was relative; this is
-#   set by XML_SetBase; it may be NULL.
-#
-#   The publicId argument is the public identifier as specified in the
-#   entity declaration, or NULL if none was specified; the whitespace
-#   in the public identifier will have been normalized as required by
-#   the XML spec.
-#
-#   The context argument specifies the parsing context in the format
-#   expected by the context argument to XML_ExternalEntityParserCreate;
-#   context is valid only until the handler returns, so if the
-#   referenced entity is to be parsed later, it must be copied.
-#   context is NULL only when the entity is a parameter entity.
-#
-#   The handler should return XML_STATUS_ERROR if processing should not
-#   continue because of a fatal error in the handling of the external
-#   entity.  In this case the calling parser will return an
-#   XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
-#
-#   Note that unlike other handlers the first argument is the parser,
-#   not userData.
-#
-
-type 
-  ExternalEntityRefHandler* = proc (parser: PParser, context: cstring, 
-                                     base: cstring, systemId: cstring, 
-                                     publicId: cstring): cint{.cdecl.}
-{.deprecated: [TExternalEntityRefHandler: ExternalEntityRefHandler].}
-# This is called in two situations:
-#   1) An entity reference is encountered for which no declaration
-#      has been read *and* this is not an error.
-#   2) An internal entity reference is read, but not expanded, because
-#      XML_SetDefaultHandler has been called.
-#   Note: skipped parameter entities in declarations and skipped general
-#         entities in attribute values cannot be reported, because
-#         the event would be out of sync with the reporting of the
-#         declarations or attribute values
-#
-
-type 
-  SkippedEntityHandler* = proc (userData: pointer, entityName: cstring, 
-                                 isParameterEntity: cint){.cdecl.}
-{.deprecated: [TSkippedEntityHandler: SkippedEntityHandler].}
-
-# This structure is filled in by the XML_UnknownEncodingHandler to
-#   provide information to the parser about encodings that are unknown
-#   to the parser.
-#
-#   The map[b] member gives information about byte sequences whose
-#   first byte is b.
-#
-#   If map[b] is c where c is >= 0, then b by itself encodes the
-#   Unicode scalar value c.
-#
-#   If map[b] is -1, then the byte sequence is malformed.
-#
-#   If map[b] is -n, where n >= 2, then b is the first byte of an
-#   n-byte sequence that encodes a single Unicode scalar value.
-#
-#   The data member will be passed as the first argument to the convert
-#   function.
-#
-#   The convert function is used to convert multibyte sequences; s will
-#   point to a n-byte sequence where map[(unsigned char)*s] == -n.  The
-#   convert function must return the Unicode scalar value represented
-#   by this byte sequence or -1 if the byte sequence is malformed.
-#
-#   The convert function may be NULL if the encoding is a single-byte
-#   encoding, that is if map[b] >= -1 for all bytes b.
-#
-#   When the parser is finished with the encoding, then if release is
-#   not NULL, it will call release passing it the data member; once
-#   release has been called, the convert function will not be called
-#   again.
-#
-#   Expat places certain restrictions on the encodings that are supported
-#   using this mechanism.
-#
-#   1. Every ASCII character that can appear in a well-formed XML document,
-#      other than the characters
-#
-#      $@\^`{}~
-#
-#      must be represented by a single byte, and that byte must be the
-#      same byte that represents that character in ASCII.
-#
-#   2. No character may require more than 4 bytes to encode.
-#
-#   3. All characters encoded must have Unicode scalar values <=
-#      0xFFFF, (i.e., characters that would be encoded by surrogates in
-#      UTF-16 are  not allowed).  Note that this restriction doesn't
-#      apply to the built-in support for UTF-8 and UTF-16.
-#
-#   4. No Unicode character may be encoded by more than one distinct
-#      sequence of bytes.
-#
-
-type 
-  Encoding*{.pure, final.} = object 
-    map*: array[0..256 - 1, cint]
-    data*: pointer
-    convert*: proc (data: pointer, s: cstring): cint{.cdecl.}
-    release*: proc (data: pointer){.cdecl.}
-{.deprecated: [TEncoding: Encoding].}
-
-
-# This is called for an encoding that is unknown to the parser.
-#
-#   The encodingHandlerData argument is that which was passed as the
-#   second argument to XML_SetUnknownEncodingHandler.
-#
-#   The name argument gives the name of the encoding as specified in
-#   the encoding declaration.
-#
-#   If the callback can provide information about the encoding, it must
-#   fill in the XML_Encoding structure, and return XML_STATUS_OK.
-#   Otherwise it must return XML_STATUS_ERROR.
-#
-#   If info does not describe a suitable encoding, then the parser will
-#   return an XML_UNKNOWN_ENCODING error.
-#
-
-type 
-  UnknownEncodingHandler* = proc (encodingHandlerData: pointer, name: cstring, 
-                                   info: ptr Encoding): cint{.cdecl.}
-{.deprecated: [TUnknownEncodingHandler: UnknownEncodingHandler].}
-
-proc setElementHandler*(parser: PParser, start: StartElementHandler, 
-                        endHandler: EndElementHandler){.cdecl, 
-    importc: "XML_SetElementHandler", dynlib: expatDll.}
-proc setStartElementHandler*(parser: PParser, handler: StartElementHandler){.
-    cdecl, importc: "XML_SetStartElementHandler", dynlib: expatDll.}
-proc setEndElementHandler*(parser: PParser, handler: EndElementHandler){.cdecl, 
-    importc: "XML_SetEndElementHandler", dynlib: expatDll.}
-proc setCharacterDataHandler*(parser: PParser, handler: CharacterDataHandler){.
-    cdecl, importc: "XML_SetCharacterDataHandler", dynlib: expatDll.}
-proc setProcessingInstructionHandler*(parser: PParser, 
-                                      handler: ProcessingInstructionHandler){.
-    cdecl, importc: "XML_SetProcessingInstructionHandler", dynlib: expatDll.}
-proc setCommentHandler*(parser: PParser, handler: CommentHandler){.cdecl, 
-    importc: "XML_SetCommentHandler", dynlib: expatDll.}
-proc setCdataSectionHandler*(parser: PParser, start: StartCdataSectionHandler, 
-                             endHandler: EndCdataSectionHandler){.cdecl, 
-    importc: "XML_SetCdataSectionHandler", dynlib: expatDll.}
-proc setStartCdataSectionHandler*(parser: PParser, 
-                                  start: StartCdataSectionHandler){.cdecl, 
-    importc: "XML_SetStartCdataSectionHandler", dynlib: expatDll.}
-proc setEndCdataSectionHandler*(parser: PParser, 
-                                endHandler: EndCdataSectionHandler){.cdecl, 
-    importc: "XML_SetEndCdataSectionHandler", dynlib: expatDll.}
-# This sets the default handler and also inhibits expansion of
-#   internal entities. These entity references will be passed to the
-#   default handler, or to the skipped entity handler, if one is set.
-#
-
-proc setDefaultHandler*(parser: PParser, handler: DefaultHandler){.cdecl, 
-    importc: "XML_SetDefaultHandler", dynlib: expatDll.}
-# This sets the default handler but does not inhibit expansion of
-#   internal entities.  The entity reference will not be passed to the
-#   default handler.
-#
-
-proc setDefaultHandlerExpand*(parser: PParser, handler: DefaultHandler){.cdecl, 
-    importc: "XML_SetDefaultHandlerExpand", dynlib: expatDll.}
-proc setDoctypeDeclHandler*(parser: PParser, start: StartDoctypeDeclHandler, 
-                            endHandler: EndDoctypeDeclHandler){.cdecl, 
-    importc: "XML_SetDoctypeDeclHandler", dynlib: expatDll.}
-proc setStartDoctypeDeclHandler*(parser: PParser, 
-                                 start: StartDoctypeDeclHandler){.cdecl, 
-    importc: "XML_SetStartDoctypeDeclHandler", dynlib: expatDll.}
-proc setEndDoctypeDeclHandler*(parser: PParser, 
-                               endHandler: EndDoctypeDeclHandler){.cdecl, 
-    importc: "XML_SetEndDoctypeDeclHandler", dynlib: expatDll.}
-proc setUnparsedEntityDeclHandler*(parser: PParser, 
-                                   handler: UnparsedEntityDeclHandler){.cdecl, 
-    importc: "XML_SetUnparsedEntityDeclHandler", dynlib: expatDll.}
-proc setNotationDeclHandler*(parser: PParser, handler: NotationDeclHandler){.
-    cdecl, importc: "XML_SetNotationDeclHandler", dynlib: expatDll.}
-proc setNamespaceDeclHandler*(parser: PParser, 
-                              start: StartNamespaceDeclHandler, 
-                              endHandler: EndNamespaceDeclHandler){.cdecl, 
-    importc: "XML_SetNamespaceDeclHandler", dynlib: expatDll.}
-proc setStartNamespaceDeclHandler*(parser: PParser, 
-                                   start: StartNamespaceDeclHandler){.cdecl, 
-    importc: "XML_SetStartNamespaceDeclHandler", dynlib: expatDll.}
-proc setEndNamespaceDeclHandler*(parser: PParser, 
-                                 endHandler: EndNamespaceDeclHandler){.cdecl, 
-    importc: "XML_SetEndNamespaceDeclHandler", dynlib: expatDll.}
-proc setNotStandaloneHandler*(parser: PParser, handler: NotStandaloneHandler){.
-    cdecl, importc: "XML_SetNotStandaloneHandler", dynlib: expatDll.}
-proc setExternalEntityRefHandler*(parser: PParser, 
-                                  handler: ExternalEntityRefHandler){.cdecl, 
-    importc: "XML_SetExternalEntityRefHandler", dynlib: expatDll.}
-# If a non-NULL value for arg is specified here, then it will be
-#   passed as the first argument to the external entity ref handler
-#   instead of the parser object.
-#
-
-proc setExternalEntityRefHandlerArg*(parser: PParser, arg: pointer){.cdecl, 
-    importc: "XML_SetExternalEntityRefHandlerArg", dynlib: expatDll.}
-proc setSkippedEntityHandler*(parser: PParser, handler: SkippedEntityHandler){.
-    cdecl, importc: "XML_SetSkippedEntityHandler", dynlib: expatDll.}
-proc setUnknownEncodingHandler*(parser: PParser, 
-                                handler: UnknownEncodingHandler, 
-                                encodingHandlerData: pointer){.cdecl, 
-    importc: "XML_SetUnknownEncodingHandler", dynlib: expatDll.}
-# This can be called within a handler for a start element, end
-#   element, processing instruction or character data.  It causes the
-#   corresponding markup to be passed to the default handler.
-#
-
-proc defaultCurrent*(parser: PParser){.cdecl, importc: "XML_DefaultCurrent", 
-                                       dynlib: expatDll.}
-# If do_nst is non-zero, and namespace processing is in effect, and
-#   a name has a prefix (i.e. an explicit namespace qualifier) then
-#   that name is returned as a triplet in a single string separated by
-#   the separator character specified when the parser was created: URI
-#   + sep + local_name + sep + prefix.
-#
-#   If do_nst is zero, then namespace information is returned in the
-#   default manner (URI + sep + local_name) whether or not the name
-#   has a prefix.
-#
-#   Note: Calling XML_SetReturnNSTriplet after XML_Parse or
-#     XML_ParseBuffer has no effect.
-#
-
-proc setReturnNSTriplet*(parser: PParser, doNst: cint){.cdecl, 
-    importc: "XML_SetReturnNSTriplet", dynlib: expatDll.}
-# This value is passed as the userData argument to callbacks. 
-
-proc setUserData*(parser: PParser, userData: pointer){.cdecl, 
-    importc: "XML_SetUserData", dynlib: expatDll.}
-# Returns the last value set by XML_SetUserData or NULL. 
-
-template getUserData*(parser: expr): expr = 
-  (cast[ptr pointer]((parser))[] )
-
-# This is equivalent to supplying an encoding argument to
-#   XML_ParserCreate. On success XML_SetEncoding returns non-zero,
-#   zero otherwise.
-#   Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
-#     has no effect and returns XML_STATUS_ERROR.
-#
-
-proc setEncoding*(parser: PParser, encoding: cstring): Status{.cdecl, 
-    importc: "XML_SetEncoding", dynlib: expatDll.}
-# If this function is called, then the parser will be passed as the
-#   first argument to callbacks instead of userData.  The userData will
-#   still be accessible using XML_GetUserData.
-#
-
-proc useParserAsHandlerArg*(parser: PParser){.cdecl, 
-    importc: "XML_UseParserAsHandlerArg", dynlib: expatDll.}
-# If useDTD == XML_TRUE is passed to this function, then the parser
-#   will assume that there is an external subset, even if none is
-#   specified in the document. In such a case the parser will call the
-#   externalEntityRefHandler with a value of NULL for the systemId
-#   argument (the publicId and context arguments will be NULL as well).
-#   Note: For the purpose of checking WFC: Entity Declared, passing
-#     useDTD == XML_TRUE will make the parser behave as if the document
-#     had a DTD with an external subset.
-#   Note: If this function is called, then this must be done before
-#     the first call to XML_Parse or XML_ParseBuffer, since it will
-#     have no effect after that.  Returns
-#     XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
-#   Note: If the document does not have a DOCTYPE declaration at all,
-#     then startDoctypeDeclHandler and endDoctypeDeclHandler will not
-#     be called, despite an external subset being parsed.
-#   Note: If XML_DTD is not defined when Expat is compiled, returns
-#     XML_ERROR_FEATURE_REQUIRES_XML_DTD.
-#
-
-proc useForeignDTD*(parser: PParser, useDTD: bool): Error{.cdecl, 
-    importc: "XML_UseForeignDTD", dynlib: expatDll.}
-# Sets the base to be used for resolving relative URIs in system
-#   identifiers in declarations.  Resolving relative identifiers is
-#   left to the application: this value will be passed through as the
-#   base argument to the XML_ExternalEntityRefHandler,
-#   XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
-#   argument will be copied.  Returns XML_STATUS_ERROR if out of memory,
-#   XML_STATUS_OK otherwise.
-#
-
-proc setBase*(parser: PParser, base: cstring): Status{.cdecl, 
-    importc: "XML_SetBase", dynlib: expatDll.}
-proc getBase*(parser: PParser): cstring{.cdecl, importc: "XML_GetBase", 
-    dynlib: expatDll.}
-# Returns the number of the attribute/value pairs passed in last call
-#   to the XML_StartElementHandler that were specified in the start-tag
-#   rather than defaulted. Each attribute/value pair counts as 2; thus
-#   this correspondds to an index into the atts array passed to the
-#   XML_StartElementHandler.
-#
-
-proc getSpecifiedAttributeCount*(parser: PParser): cint{.cdecl, 
-    importc: "XML_GetSpecifiedAttributeCount", dynlib: expatDll.}
-# Returns the index of the ID attribute passed in the last call to
-#   XML_StartElementHandler, or -1 if there is no ID attribute.  Each
-#   attribute/value pair counts as 2; thus this correspondds to an
-#   index into the atts array passed to the XML_StartElementHandler.
-#
-
-proc getIdAttributeIndex*(parser: PParser): cint{.cdecl, 
-    importc: "XML_GetIdAttributeIndex", dynlib: expatDll.}
-# Parses some input. Returns XML_STATUS_ERROR if a fatal error is
-#   detected.  The last call to XML_Parse must have isFinal true; len
-#   may be zero for this call (or any other).
-#
-#   Though the return values for these functions has always been
-#   described as a Boolean value, the implementation, at least for the
-#   1.95.x series, has always returned exactly one of the XML_Status
-#   values.
-#
-
-proc parse*(parser: PParser, s: cstring, len: cint, isFinal: cint): Status{.
-    cdecl, importc: "XML_Parse", dynlib: expatDll.}
-proc getBuffer*(parser: PParser, len: cint): pointer{.cdecl, 
-    importc: "XML_GetBuffer", dynlib: expatDll.}
-proc parseBuffer*(parser: PParser, len: cint, isFinal: cint): Status{.cdecl, 
-    importc: "XML_ParseBuffer", dynlib: expatDll.}
-# Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
-#   Must be called from within a call-back handler, except when aborting
-#   (resumable = 0) an already suspended parser. Some call-backs may
-#   still follow because they would otherwise get lost. Examples:
-#   - endElementHandler() for empty elements when stopped in
-#     startElementHandler(), 
-#   - endNameSpaceDeclHandler() when stopped in endElementHandler(), 
-#   and possibly others.
-#
-#   Can be called from most handlers, including DTD related call-backs,
-#   except when parsing an external parameter entity and resumable != 0.
-#   Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
-#   Possible error codes: 
-#   - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
-#   - XML_ERROR_FINISHED: when the parser has already finished.
-#   - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
-#
-#   When resumable != 0 (true) then parsing is suspended, that is, 
-#   XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 
-#   Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
-#   return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
-#
-#   Note*:
-#   This will be applied to the current parser instance only, that is, if
-#   there is a parent parser then it will continue parsing when the
-#   externalEntityRefHandler() returns. It is up to the implementation of
-#   the externalEntityRefHandler() to call XML_StopParser() on the parent
-#   parser (recursively), if one wants to stop parsing altogether.
-#
-#   When suspended, parsing can be resumed by calling XML_ResumeParser(). 
-#
-
-proc stopParser*(parser: PParser, resumable: bool): Status{.cdecl, 
-    importc: "XML_StopParser", dynlib: expatDll.}
-# Resumes parsing after it has been suspended with XML_StopParser().
-#   Must not be called from within a handler call-back. Returns same
-#   status codes as XML_Parse() or XML_ParseBuffer().
-#   Additional error code XML_ERROR_NOT_SUSPENDED possible.   
-#
-#   Note*:
-#   This must be called on the most deeply nested child parser instance
-#   first, and on its parent parser only after the child parser has finished,
-#   to be applied recursively until the document entity's parser is restarted.
-#   That is, the parent parser will not resume by itself and it is up to the
-#   application to call XML_ResumeParser() on it at the appropriate moment.
-#
-
-proc resumeParser*(parser: PParser): Status{.cdecl, 
-    importc: "XML_ResumeParser", dynlib: expatDll.}
-type 
-  TParsing* = enum 
-    INITIALIZED, PARSING, FINISHED, SUSPENDED
-  ParsingStatus*{.pure, final.} = object 
-    parsing*: TParsing
-    finalBuffer*: bool
-{.deprecated: [#TParsing: Parsing, # Naming conflict if we drop the `T`
-              TParsingStatus: ParsingStatus].}
-
-# Returns status of parser with respect to being initialized, parsing,
-#   finished, or suspended and processing the final buffer.
-#   XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
-#   XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
-#
-
-proc getParsingStatus*(parser: PParser, status: ptr ParsingStatus){.cdecl, 
-    importc: "XML_GetParsingStatus", dynlib: expatDll.}
-# Creates an XML_Parser object that can parse an external general
-#   entity; context is a '\0'-terminated string specifying the parse
-#   context; encoding is a '\0'-terminated string giving the name of
-#   the externally specified encoding, or NULL if there is no
-#   externally specified encoding.  The context string consists of a
-#   sequence of tokens separated by formfeeds (\f); a token consisting
-#   of a name specifies that the general entity of the name is open; a
-#   token of the form prefix=uri specifies the namespace for a
-#   particular prefix; a token of the form =uri specifies the default
-#   namespace.  This can be called at any point after the first call to
-#   an ExternalEntityRefHandler so longer as the parser has not yet
-#   been freed.  The new parser is completely independent and may
-#   safely be used in a separate thread.  The handlers and userData are
-#   initialized from the parser argument.  Returns NULL if out of memory.
-#   Otherwise returns a new XML_Parser object.
-#
-
-proc externalEntityParserCreate*(parser: PParser, context: cstring, 
-                                 encoding: cstring): PParser{.cdecl, 
-    importc: "XML_ExternalEntityParserCreate", dynlib: expatDll.}
-type 
-  ParamEntityParsing* = enum 
-    PARAM_ENTITY_PARSING_NEVER, PARAM_ENTITY_PARSING_UNLESS_STANDALONE, 
-    PARAM_ENTITY_PARSING_ALWAYS
-{.deprecated: [TParamEntityParsing: ParamEntityParsing].}
-
-# Controls parsing of parameter entities (including the external DTD
-#   subset). If parsing of parameter entities is enabled, then
-#   references to external parameter entities (including the external
-#   DTD subset) will be passed to the handler set with
-#   XML_SetExternalEntityRefHandler.  The context passed will be 0.
-#
-#   Unlike external general entities, external parameter entities can
-#   only be parsed synchronously.  If the external parameter entity is
-#   to be parsed, it must be parsed during the call to the external
-#   entity ref handler: the complete sequence of
-#   XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
-#   XML_ParserFree calls must be made during this call.  After
-#   XML_ExternalEntityParserCreate has been called to create the parser
-#   for the external parameter entity (context must be 0 for this
-#   call), it is illegal to make any calls on the old parser until
-#   XML_ParserFree has been called on the newly created parser.
-#   If the library has been compiled without support for parameter
-#   entity parsing (ie without XML_DTD being defined), then
-#   XML_SetParamEntityParsing will return 0 if parsing of parameter
-#   entities is requested; otherwise it will return non-zero.
-#   Note: If XML_SetParamEntityParsing is called after XML_Parse or
-#      XML_ParseBuffer, then it has no effect and will always return 0.
-#
-
-proc setParamEntityParsing*(parser: PParser, parsing: ParamEntityParsing): cint{.
-    cdecl, importc: "XML_SetParamEntityParsing", dynlib: expatDll.}
-# If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
-#   XML_GetErrorCode returns information about the error.
-#
-
-proc getErrorCode*(parser: PParser): Error{.cdecl, importc: "XML_GetErrorCode", 
-    dynlib: expatDll.}
-# These functions return information about the current parse
-#   location.  They may be called from any callback called to report
-#   some parse event; in this case the location is the location of the
-#   first of the sequence of characters that generated the event.  When
-#   called from callbacks generated by declarations in the document
-#   prologue, the location identified isn't as neatly defined, but will
-#   be within the relevant markup.  When called outside of the callback
-#   functions, the position indicated will be just past the last parse
-#   event (regardless of whether there was an associated callback).
-#   
-#   They may also be called after returning from a call to XML_Parse
-#   or XML_ParseBuffer.  If the return value is XML_STATUS_ERROR then
-#   the location is the location of the character at which the error
-#   was detected; otherwise the location is the location of the last
-#   parse event, as described above.
-#
-
-proc getCurrentLineNumber*(parser: PParser): int{.cdecl, 
-    importc: "XML_GetCurrentLineNumber", dynlib: expatDll.}
-proc getCurrentColumnNumber*(parser: PParser): int{.cdecl, 
-    importc: "XML_GetCurrentColumnNumber", dynlib: expatDll.}
-proc getCurrentByteIndex*(parser: PParser): int{.cdecl, 
-    importc: "XML_GetCurrentByteIndex", dynlib: expatDll.}
-# Return the number of bytes in the current event.
-#   Returns 0 if the event is in an internal entity.
-#
-
-proc getCurrentByteCount*(parser: PParser): cint{.cdecl, 
-    importc: "XML_GetCurrentByteCount", dynlib: expatDll.}
-# If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
-#   the integer pointed to by offset to the offset within this buffer
-#   of the current parse position, and sets the integer pointed to by size
-#   to the size of this buffer (the number of input bytes). Otherwise
-#   returns a NULL pointer. Also returns a NULL pointer if a parse isn't
-#   active.
-#
-#   NOTE: The character pointer returned should not be used outside
-#   the handler that makes the call.
-#
-
-proc getInputContext*(parser: PParser, offset: ptr cint, size: ptr cint): cstring{.
-    cdecl, importc: "XML_GetInputContext", dynlib: expatDll.}
-# Frees the content model passed to the element declaration handler 
-
-proc freeContentModel*(parser: PParser, model: ptr Content){.cdecl, 
-    importc: "XML_FreeContentModel", dynlib: expatDll.}
-# Exposing the memory handling functions used in Expat 
-
-proc memMalloc*(parser: PParser, size: int): pointer{.cdecl, 
-    importc: "XML_MemMalloc", dynlib: expatDll.}
-proc memRealloc*(parser: PParser, p: pointer, size: int): pointer{.cdecl, 
-    importc: "XML_MemRealloc", dynlib: expatDll.}
-proc memFree*(parser: PParser, p: pointer){.cdecl, importc: "XML_MemFree", 
-    dynlib: expatDll.}
-# Frees memory used by the parser. 
-
-proc parserFree*(parser: PParser){.cdecl, importc: "XML_ParserFree", 
-                                   dynlib: expatDll.}
-# Returns a string describing the error. 
-
-proc errorString*(code: Error): cstring{.cdecl, importc: "XML_ErrorString", 
-    dynlib: expatDll.}
-# Return a string containing the version number of this expat 
-
-proc expatVersion*(): cstring{.cdecl, importc: "XML_ExpatVersion", 
-                               dynlib: expatDll.}
-type 
-  Expat_Version*{.pure, final.} = object 
-    major*: cint
-    minor*: cint
-    micro*: cint
-{.deprecated: [TExpat_Version: ExpatVersion].}
-
-# Return an XML_Expat_Version structure containing numeric version
-#   number information for this version of expat.
-#
-
-proc expatVersionInfo*(): ExpatVersion{.cdecl, 
-    importc: "XML_ExpatVersionInfo", dynlib: expatDll.}
-# Added in Expat 1.95.5. 
-
-type 
-  FeatureEnum* = enum 
-    FEATURE_END = 0, FEATURE_UNICODE, FEATURE_UNICODE_WCHAR_T, FEATURE_DTD, 
-    FEATURE_CONTEXT_BYTES, FEATURE_MIN_SIZE, FEATURE_SIZEOF_XML_CHAR, 
-    FEATURE_SIZEOF_XML_LCHAR, FEATURE_NS, FEATURE_LARGE_SIZE # Additional features must be added to the end of this enum. 
-  Feature*{.pure, final.} = object 
-    feature*: FeatureEnum
-    name*: cstring
-    value*: int
-{.deprecated: [TFeatureEnum: FeatureEnum, TFeature: Feature].}
-
-proc getFeatureList*(): ptr Feature{.cdecl, importc: "XML_GetFeatureList", 
-                                      dynlib: expatDll.}
-# Expat follows the GNU/Linux convention of odd number minor version for
-#   beta/development releases and even number minor version for stable
-#   releases. Micro is bumped with each release, and set to 0 with each
-#   change to major or minor version.
-#
-
-const 
-  MAJOR_VERSION* = 2
-  MINOR_VERSION* = 0
-  MICRO_VERSION* = 1
diff --git a/lib/wrappers/iup.nim b/lib/wrappers/iup.nim
index 93e14cccd..cbd9b5ae9 100644
--- a/lib/wrappers/iup.nim
+++ b/lib/wrappers/iup.nim
@@ -1,6 +1,12 @@
 #
-#    Binding for the IUP GUI toolkit
-#       (c) 2012 Andreas Rumpf
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
 #    C header files translated by hand
 #    Licence of IUP follows:
 
diff --git a/lib/wrappers/joyent_http_parser.nim b/lib/wrappers/joyent_http_parser.nim
index 2fed392b9..f7412d2b8 100644
--- a/lib/wrappers/joyent_http_parser.nim
+++ b/lib/wrappers/joyent_http_parser.nim
@@ -1,6 +1,15 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
 type
   csize = int
-  
+
   HttpDataProc* = proc (a2: ptr HttpParser, at: cstring, length: csize): cint {.cdecl.}
   HttpProc* = proc (a2: ptr HttpParser): cint {.cdecl.}
 
diff --git a/lib/wrappers/libcurl.nim b/lib/wrappers/libcurl.nim
deleted file mode 100644
index 924879e75..000000000
--- a/lib/wrappers/libcurl.nim
+++ /dev/null
@@ -1,512 +0,0 @@
-#
-#    $Id: header,v 1.1 2000/07/13 06:33:45 michael Exp $
-#    This file is part of the Free Pascal packages
-#    Copyright (c) 1999-2000 by the Free Pascal development team
-#
-#    See the file COPYING.FPC, included in this distribution,
-#    for details about the copyright.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# **********************************************************************
-#
-#   the curl library is governed by its own copyright, see the curl
-#   website for this. 
-# 
-
-{.deadCodeElim: on.}
-
-import 
-  times
-
-when defined(windows): 
-  const 
-    libname = "libcurl.dll"
-elif defined(macosx): 
-  const 
-    libname = "libcurl-7.19.3.dylib"
-elif defined(unix): 
-  const 
-    libname = "libcurl.so.4"
-type 
-  Pcalloc_callback* = ptr Calloc_callback
-  Pclosepolicy* = ptr Closepolicy
-  Pforms* = ptr Forms
-  Pftpauth* = ptr Ftpauth
-  Pftpmethod* = ptr Ftpmethod
-  Pftpssl* = ptr Ftpssl
-  PHTTP_VERSION* = ptr HTTP_VERSION
-  Phttppost* = ptr Httppost
-  PPcurl_httppost* = ptr Phttppost
-  Pinfotype* = ptr Infotype
-  Plock_access* = ptr Lock_access
-  Plock_data* = ptr Lock_data
-  Pmalloc_callback* = ptr Malloc_callback
-  PNETRC_OPTION* = ptr NETRC_OPTION
-  Pproxytype* = ptr Proxytype
-  Prealloc_callback* = ptr Realloc_callback
-  Pslist* = ptr Slist
-  Psocket* = ptr Socket
-  PSSL_VERSION* = ptr SSL_VERSION
-  Pstrdup_callback* = ptr Strdup_callback
-  PTIMECOND* = ptr TIMECOND
-  Pversion_info_data* = ptr Version_info_data
-  Pcode* = ptr Code
-  PFORMcode* = ptr FORMcode
-  Pformoption* = ptr Formoption
-  PINFO* = ptr INFO
-  Piocmd* = ptr Iocmd
-  Pioerr* = ptr Ioerr
-  PM* = ptr M
-  PMcode* = ptr Mcode
-  PMoption* = ptr Moption
-  PMSG* = ptr MSG
-  Poption* = ptr Option
-  PSH* = ptr SH
-  PSHcode* = ptr SHcode
-  PSHoption* = ptr SHoption
-  Pversion* = ptr Version
-  Pfd_set* = pointer
-  PCurl* = ptr Curl
-  Curl* = pointer
-  Httppost*{.final, pure.} = object 
-    next*: Phttppost
-    name*: cstring
-    namelength*: int32
-    contents*: cstring
-    contentslength*: int32
-    buffer*: cstring
-    bufferlength*: int32
-    contenttype*: cstring
-    contentheader*: Pslist
-    more*: Phttppost
-    flags*: int32
-    showfilename*: cstring
-
-  Progress_callback* = proc (clientp: pointer, dltotal: float64, 
-                              dlnow: float64, ultotal: float64, 
-                              ulnow: float64): int32 {.cdecl.}
-  Write_callback* = proc (buffer: cstring, size: int, nitems: int, 
-                           outstream: pointer): int{.cdecl.}
-  Read_callback* = proc (buffer: cstring, size: int, nitems: int, 
-                          instream: pointer): int{.cdecl.}
-  Passwd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring, 
-                            buflen: int32): int32{.cdecl.}
-  Ioerr* = enum 
-    IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST
-  Iocmd* = enum 
-    IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST
-  Ioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Ioerr{.
-      cdecl.}
-  Malloc_callback* = proc (size: int): pointer{.cdecl.}
-  Free_callback* = proc (p: pointer){.cdecl.}
-  Realloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.}
-  Strdup_callback* = proc (str: cstring): cstring{.cdecl.}
-  Calloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.}
-  Infotype* = enum 
-    INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT, 
-    INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END
-  Debug_callback* = proc (handle: PCurl, theType: Infotype, data: cstring, 
-                           size: int, userptr: pointer): int32{.cdecl.}
-  Code* = enum 
-    E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT, 
-    E_URL_MALFORMAT_USER, E_COULDNT_RESOLVE_PROXY, E_COULDNT_RESOLVE_HOST, 
-    E_COULDNT_CONNECT, E_FTP_WEIRD_SERVER_REPLY, E_FTP_ACCESS_DENIED, 
-    E_FTP_USER_PASSWORD_INCORRECT, E_FTP_WEIRD_PASS_REPLY, 
-    E_FTP_WEIRD_USER_REPLY, E_FTP_WEIRD_PASV_REPLY, E_FTP_WEIRD_227_FORMAT, 
-    E_FTP_CANT_GET_HOST, E_FTP_CANT_RECONNECT, E_FTP_COULDNT_SET_BINARY, 
-    E_PARTIAL_FILE, E_FTP_COULDNT_RETR_FILE, E_FTP_WRITE_ERROR, 
-    E_FTP_QUOTE_ERROR, E_HTTP_RETURNED_ERROR, E_WRITE_ERROR, E_MALFORMAT_USER, 
-    E_FTP_COULDNT_STOR_FILE, E_READ_ERROR, E_OUT_OF_MEMORY, 
-    E_OPERATION_TIMEOUTED, E_FTP_COULDNT_SET_ASCII, E_FTP_PORT_FAILED, 
-    E_FTP_COULDNT_USE_REST, E_FTP_COULDNT_GET_SIZE, E_HTTP_RANGE_ERROR, 
-    E_HTTP_POST_ERROR, E_SSL_CONNECT_ERROR, E_BAD_DOWNLOAD_RESUME, 
-    E_FILE_COULDNT_READ_FILE, E_LDAP_CANNOT_BIND, E_LDAP_SEARCH_FAILED, 
-    E_LIBRARY_NOT_FOUND, E_FUNCTION_NOT_FOUND, E_ABORTED_BY_CALLBACK, 
-    E_BAD_FUNCTION_ARGUMENT, E_BAD_CALLING_ORDER, E_INTERFACE_FAILED, 
-    E_BAD_PASSWORD_ENTERED, E_TOO_MANY_REDIRECTS, E_UNKNOWN_TELNET_OPTION, 
-    E_TELNET_OPTION_SYNTAX, E_OBSOLETE, E_SSL_PEER_CERTIFICATE, E_GOT_NOTHING, 
-    E_SSL_ENGINE_NOTFOUND, E_SSL_ENGINE_SETFAILED, E_SEND_ERROR, E_RECV_ERROR, 
-    E_SHARE_IN_USE, E_SSL_CERTPROBLEM, E_SSL_CIPHER, E_SSL_CACERT, 
-    E_BAD_CONTENT_ENCODING, E_LDAP_INVALID_URL, E_FILESIZE_EXCEEDED, 
-    E_FTP_SSL_FAILED, E_SEND_FAIL_REWIND, E_SSL_ENGINE_INITFAILED, 
-    E_LOGIN_DENIED, E_TFTP_NOTFOUND, E_TFTP_PERM, E_TFTP_DISKFULL, 
-    E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER, 
-    E_CONV_FAILED, E_CONV_REQD, LAST
-  Conv_callback* = proc (buffer: cstring, len: int): Code{.cdecl.}
-  Ssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Code{.cdecl.}
-  Proxytype* = enum 
-    PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5
-  Ftpssl* = enum 
-    FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST
-  Ftpauth* = enum 
-    FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST
-  Ftpmethod* = enum 
-    FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD, 
-    FTPMETHOD_LAST
-  Option* = enum 
-    OPT_PORT = 0 + 3, OPT_TIMEOUT = 0 + 13, OPT_INFILESIZE = 0 + 14, 
-    OPT_LOW_SPEED_LIMIT = 0 + 19, OPT_LOW_SPEED_TIME = 0 + 20, 
-    OPT_RESUME_FROM = 0 + 21, OPT_CRLF = 0 + 27, OPT_SSLVERSION = 0 + 32, 
-    OPT_TIMECONDITION = 0 + 33, OPT_TIMEVALUE = 0 + 34, OPT_VERBOSE = 0 + 41, 
-    OPT_HEADER = 0 + 42, OPT_NOPROGRESS = 0 + 43, OPT_NOBODY = 0 + 44, 
-    OPT_FAILONERROR = 0 + 45, OPT_UPLOAD = 0 + 46, OPT_POST = 0 + 47, 
-    OPT_FTPLISTONLY = 0 + 48, OPT_FTPAPPEND = 0 + 50, OPT_NETRC = 0 + 51, 
-    OPT_FOLLOWLOCATION = 0 + 52, OPT_TRANSFERTEXT = 0 + 53, OPT_PUT = 0 + 54, 
-    OPT_AUTOREFERER = 0 + 58, OPT_PROXYPORT = 0 + 59, 
-    OPT_POSTFIELDSIZE = 0 + 60, OPT_HTTPPROXYTUNNEL = 0 + 61, 
-    OPT_SSL_VERIFYPEER = 0 + 64, OPT_MAXREDIRS = 0 + 68, OPT_FILETIME = 0 + 69, 
-    OPT_MAXCONNECTS = 0 + 71, OPT_CLOSEPOLICY = 0 + 72, 
-    OPT_FRESH_CONNECT = 0 + 74, OPT_FORBID_REUSE = 0 + 75, 
-    OPT_CONNECTTIMEOUT = 0 + 78, OPT_HTTPGET = 0 + 80, 
-    OPT_SSL_VERIFYHOST = 0 + 81, OPT_HTTP_VERSION = 0 + 84, 
-    OPT_FTP_USE_EPSV = 0 + 85, OPT_SSLENGINE_DEFAULT = 0 + 90, 
-    OPT_DNS_USE_GLOBAL_CACHE = 0 + 91, OPT_DNS_CACHE_TIMEOUT = 0 + 92, 
-    OPT_COOKIESESSION = 0 + 96, OPT_BUFFERSIZE = 0 + 98, OPT_NOSIGNAL = 0 + 99, 
-    OPT_PROXYTYPE = 0 + 101, OPT_UNRESTRICTED_AUTH = 0 + 105, 
-    OPT_FTP_USE_EPRT = 0 + 106, OPT_HTTPAUTH = 0 + 107, 
-    OPT_FTP_CREATE_MISSING_DIRS = 0 + 110, OPT_PROXYAUTH = 0 + 111, 
-    OPT_FTP_RESPONSE_TIMEOUT = 0 + 112, OPT_IPRESOLVE = 0 + 113, 
-    OPT_MAXFILESIZE = 0 + 114, OPT_FTP_SSL = 0 + 119, OPT_TCP_NODELAY = 0 + 121, 
-    OPT_FTPSSLAUTH = 0 + 129, OPT_IGNORE_CONTENT_LENGTH = 0 + 136, 
-    OPT_FTP_SKIP_PASV_IP = 0 + 137, OPT_FTP_FILEMETHOD = 0 + 138, 
-    OPT_LOCALPORT = 0 + 139, OPT_LOCALPORTRANGE = 0 + 140, 
-    OPT_CONNECT_ONLY = 0 + 141, OPT_FILE = 10000 + 1, OPT_URL = 10000 + 2, 
-    OPT_PROXY = 10000 + 4, OPT_USERPWD = 10000 + 5, 
-    OPT_PROXYUSERPWD = 10000 + 6, OPT_RANGE = 10000 + 7, OPT_INFILE = 10000 + 9, 
-    OPT_ERRORBUFFER = 10000 + 10, OPT_POSTFIELDS = 10000 + 15, 
-    OPT_REFERER = 10000 + 16, OPT_FTPPORT = 10000 + 17, 
-    OPT_USERAGENT = 10000 + 18, OPT_COOKIE = 10000 + 22, 
-    OPT_HTTPHEADER = 10000 + 23, OPT_HTTPPOST = 10000 + 24, 
-    OPT_SSLCERT = 10000 + 25, OPT_SSLCERTPASSWD = 10000 + 26, 
-    OPT_QUOTE = 10000 + 28, OPT_WRITEHEADER = 10000 + 29, 
-    OPT_COOKIEFILE = 10000 + 31, OPT_CUSTOMREQUEST = 10000 + 36, 
-    OPT_STDERR = 10000 + 37, OPT_POSTQUOTE = 10000 + 39, 
-    OPT_WRITEINFO = 10000 + 40, OPT_PROGRESSDATA = 10000 + 57, 
-    OPT_INTERFACE = 10000 + 62, OPT_KRB4LEVEL = 10000 + 63, 
-    OPT_CAINFO = 10000 + 65, OPT_TELNETOPTIONS = 10000 + 70, 
-    OPT_RANDOM_FILE = 10000 + 76, OPT_EGDSOCKET = 10000 + 77, 
-    OPT_COOKIEJAR = 10000 + 82, OPT_SSL_CIPHER_LIST = 10000 + 83, 
-    OPT_SSLCERTTYPE = 10000 + 86, OPT_SSLKEY = 10000 + 87, 
-    OPT_SSLKEYTYPE = 10000 + 88, OPT_SSLENGINE = 10000 + 89, 
-    OPT_PREQUOTE = 10000 + 93, OPT_DEBUGDATA = 10000 + 95, 
-    OPT_CAPATH = 10000 + 97, OPT_SHARE = 10000 + 100, 
-    OPT_ENCODING = 10000 + 102, OPT_PRIVATE = 10000 + 103, 
-    OPT_HTTP200ALIASES = 10000 + 104, OPT_SSL_CTX_DATA = 10000 + 109, 
-    OPT_NETRC_FILE = 10000 + 118, OPT_SOURCE_USERPWD = 10000 + 123, 
-    OPT_SOURCE_PREQUOTE = 10000 + 127, OPT_SOURCE_POSTQUOTE = 10000 + 128, 
-    OPT_IOCTLDATA = 10000 + 131, OPT_SOURCE_URL = 10000 + 132, 
-    OPT_SOURCE_QUOTE = 10000 + 133, OPT_FTP_ACCOUNT = 10000 + 134, 
-    OPT_COOKIELIST = 10000 + 135, OPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147, 
-    OPT_LASTENTRY = 10000 + 148, OPT_WRITEFUNCTION = 20000 + 11, 
-    OPT_READFUNCTION = 20000 + 12, OPT_PROGRESSFUNCTION = 20000 + 56, 
-    OPT_HEADERFUNCTION = 20000 + 79, OPT_DEBUGFUNCTION = 20000 + 94, 
-    OPT_SSL_CTX_FUNCTION = 20000 + 108, OPT_IOCTLFUNCTION = 20000 + 130, 
-    OPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142, 
-    OPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143, 
-    OPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144, 
-    OPT_INFILESIZE_LARGE = 30000 + 115, OPT_RESUME_FROM_LARGE = 30000 + 116, 
-    OPT_MAXFILESIZE_LARGE = 30000 + 117, OPT_POSTFIELDSIZE_LARGE = 30000 + 120, 
-    OPT_MAX_SEND_SPEED_LARGE = 30000 + 145, 
-    OPT_MAX_RECV_SPEED_LARGE = 30000 + 146
-  HTTP_VERSION* = enum 
-    HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST
-  NETRC_OPTION* = enum 
-    NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST
-  SSL_VERSION* = enum 
-    SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3, 
-    SSLVERSION_LAST
-  TIMECOND* = enum 
-    TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD, 
-    TIMECOND_LAST
-  Formoption* = enum 
-    FORM_NOTHING, FORM_COPYNAME, FORM_PTRNAME, FORM_NAMELENGTH, 
-    FORM_COPYCONTENTS, FORM_PTRCONTENTS, FORM_CONTENTSLENGTH, FORM_FILECONTENT, 
-    FORM_ARRAY, FORM_OBSOLETE, FORM_FILE, FORM_BUFFER, FORM_BUFFERPTR, 
-    FORM_BUFFERLENGTH, FORM_CONTENTTYPE, FORM_CONTENTHEADER, FORM_FILENAME, 
-    FORM_END, FORM_OBSOLETE2, FORM_LASTENTRY
-  Forms*{.pure, final.} = object 
-    option*: Formoption
-    value*: cstring
-
-  FORMcode* = enum 
-    FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL, 
-    FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY, 
-    FORMADD_DISABLED, FORMADD_LAST
-  Formget_callback* = proc (arg: pointer, buf: cstring, length: int): int{.
-      cdecl.}
-  Slist*{.pure, final.} = object 
-    data*: cstring
-    next*: Pslist
-
-  INFO* = enum 
-    INFO_NONE = 0, INFO_LASTONE = 30, INFO_EFFECTIVE_URL = 0x00100000 + 1, 
-    INFO_CONTENT_TYPE = 0x00100000 + 18, INFO_PRIVATE = 0x00100000 + 21, 
-    INFO_FTP_ENTRY_PATH = 0x00100000 + 30, INFO_RESPONSE_CODE = 0x00200000 + 2, 
-    INFO_HEADER_SIZE = 0x00200000 + 11, INFO_REQUEST_SIZE = 0x00200000 + 12, 
-    INFO_SSL_VERIFYRESULT = 0x00200000 + 13, INFO_FILETIME = 0x00200000 + 14, 
-    INFO_REDIRECT_COUNT = 0x00200000 + 20, 
-    INFO_HTTP_CONNECTCODE = 0x00200000 + 22, 
-    INFO_HTTPAUTH_AVAIL = 0x00200000 + 23, 
-    INFO_PROXYAUTH_AVAIL = 0x00200000 + 24, INFO_OS_ERRNO = 0x00200000 + 25, 
-    INFO_NUM_CONNECTS = 0x00200000 + 26, INFO_LASTSOCKET = 0x00200000 + 29, 
-    INFO_TOTAL_TIME = 0x00300000 + 3, INFO_NAMELOOKUP_TIME = 0x00300000 + 4, 
-    INFO_CONNECT_TIME = 0x00300000 + 5, INFO_PRETRANSFER_TIME = 0x00300000 + 6, 
-    INFO_SIZE_UPLOAD = 0x00300000 + 7, INFO_SIZE_DOWNLOAD = 0x00300000 + 8, 
-    INFO_SPEED_DOWNLOAD = 0x00300000 + 9, INFO_SPEED_UPLOAD = 0x00300000 + 10, 
-    INFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15, 
-    INFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16, 
-    INFO_STARTTRANSFER_TIME = 0x00300000 + 17, 
-    INFO_REDIRECT_TIME = 0x00300000 + 19, INFO_SSL_ENGINES = 0x00400000 + 27, 
-    INFO_COOKIELIST = 0x00400000 + 28
-  Closepolicy* = enum 
-    CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED, 
-    CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK, 
-    CLOSEPOLICY_LAST
-  Lock_data* = enum 
-    LOCK_DATA_NONE = 0, LOCK_DATA_SHARE, LOCK_DATA_COOKIE, LOCK_DATA_DNS, 
-    LOCK_DATA_SSL_SESSION, LOCK_DATA_CONNECT, LOCK_DATA_LAST
-  Lock_access* = enum 
-    LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2, 
-    LOCK_ACCESS_LAST
-  Lock_function* = proc (handle: PCurl, data: Lock_data,
-                          locktype: Lock_access, 
-                          userptr: pointer){.cdecl.}
-  Unlock_function* = proc (handle: PCurl, data: Lock_data, userptr: pointer){.
-      cdecl.}
-  SH* = pointer
-  SHcode* = enum 
-    SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST
-  SHoption* = enum 
-    SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, 
-    SHOPT_USERDATA, SHOPT_LAST
-  Version* = enum 
-    VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST
-  Version_info_data*{.pure, final.} = object 
-    age*: Version
-    version*: cstring
-    version_num*: int32
-    host*: cstring
-    features*: int32
-    ssl_version*: cstring
-    ssl_version_num*: int32
-    libz_version*: cstring
-    protocols*: cstringArray
-    ares*: cstring
-    ares_num*: int32
-    libidn*: cstring
-    iconv_ver_num*: int32
-
-  M* = pointer
-  Socket* = int32
-  Mcode* = enum 
-    M_CALL_MULTI_PERFORM = - 1, M_OK = 0, M_BAD_HANDLE, M_BAD_EASY_HANDLE, 
-    M_OUT_OF_MEMORY, M_INTERNAL_ERROR, M_BAD_SOCKET, M_UNKNOWN_OPTION, M_LAST
-  MSGEnum* = enum 
-    MSG_NONE, MSG_DONE, MSG_LAST
-  Msg*{.pure, final.} = object 
-    msg*: MSGEnum
-    easy_handle*: PCurl
-    whatever*: pointer        #data : record
-                              #      case longint of
-                              #        0 : ( whatever : pointer );
-                              #        1 : ( result : CURLcode );
-                              #    end;
-  
-  Socket_callback* = proc (easy: PCurl, s: Socket, what: int32, 
-                            userp, socketp: pointer): int32{.cdecl.}
-  Moption* = enum 
-    MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3, 
-    MOPT_SOCKETFUNCTION = 20000 + 1
-{.deprecated: [TMsg: Msg, TCurl: Curl, Thttppost: Httppost,
-    Tprogress_callback: Progress_callback, Twrite_callback: Write_callback,
-    Tread_callback: Read_callback, Tpasswd_callback: Passwd_callback, Tioerr: Ioerr,
-    Tiocmd: Iocmd, Tioctl_callback: Ioctl_callback, Tmalloc_callback: Malloc_callback,
-    Tfree_callback: Free_callback, Trealloc_callback: Realloc_callback,
-    Tstrdup_callback: Strdup_callback, Tcalloc_callback: Calloc_callback,
-    Tinfotype: Infotype, Tdebug_callback: Debug_callback, Tcode: Code,
-    Tconv_callback: Conv_callback, Tssl_ctx_callback: Ssl_ctx_callback,
-    Tproxytype: Proxytype, Tftpssl: Ftpssl, Tftpauth: Ftpauth, Tftpmethod: Ftpmethod,
-    Toption: Option, THTTP_VERSION: HTTP_VERSION, TNETRC_OPTION: NETRC_OPTION,
-    TSSL_VERSION: SSL_VERSION, TTIMECOND: TIMECOND, Tformoption: Formoption,
-    Tforms: Forms, TFORMcode: FORMcode, Tformget_callback: Formget_callback,
-    Tslist: Slist, TINFO: INFO, Tclosepolicy: Closepolicy, Tlock_data: Lock_data,
-    Tlock_access: Lock_access, Tlock_function: Lock_function,
-    Tunlock_function: Unlock_function, TSH: Sh, TSHcode: SHcode, TSHoption: SHoption,
-    Tversion: Version, Tversion_info_data: Version_info_data, TM: M, Tsocket: Socket,
-    TMcode: Mcode, TMSGEnum: MsGEnum, Tsocket_callback: Socket_callback,
-    TMoption: Moption].}
-
-const 
-  OPT_SSLKEYPASSWD* = OPT_SSLCERTPASSWD
-  AUTH_ANY* = not (0)
-  AUTH_BASIC* = 1 shl 0
-  AUTH_ANYSAFE* = not (AUTH_BASIC)
-  AUTH_DIGEST* = 1 shl 1
-  AUTH_GSSNEGOTIATE* = 1 shl 2
-  AUTH_NONE* = 0
-  AUTH_NTLM* = 1 shl 3
-  E_ALREADY_COMPLETE* = 99999
-  E_FTP_BAD_DOWNLOAD_RESUME* = E_BAD_DOWNLOAD_RESUME
-  E_FTP_PARTIAL_FILE* = E_PARTIAL_FILE
-  E_HTTP_NOT_FOUND* = E_HTTP_RETURNED_ERROR
-  E_HTTP_PORT_FAILED* = E_INTERFACE_FAILED
-  E_OPERATION_TIMEDOUT* = E_OPERATION_TIMEOUTED
-  ERROR_SIZE* = 256
-  FORMAT_OFF_T* = "%ld"
-  GLOBAL_NOTHING* = 0
-  GLOBAL_SSL* = 1 shl 0
-  GLOBAL_WIN32* = 1 shl 1
-  GLOBAL_ALL* = GLOBAL_SSL or GLOBAL_WIN32
-  GLOBAL_DEFAULT* = GLOBAL_ALL
-  INFO_DOUBLE* = 0x00300000
-  INFO_HTTP_CODE* = INFO_RESPONSE_CODE
-  INFO_LONG* = 0x00200000
-  INFO_MASK* = 0x000FFFFF
-  INFO_SLIST* = 0x00400000
-  INFO_STRING* = 0x00100000
-  INFO_TYPEMASK* = 0x00F00000
-  IPRESOLVE_V4* = 1
-  IPRESOLVE_V6* = 2
-  IPRESOLVE_WHATEVER* = 0
-  MAX_WRITE_SIZE* = 16384
-  M_CALL_MULTI_SOCKET* = M_CALL_MULTI_PERFORM
-  OPT_CLOSEFUNCTION* = - (5)
-  OPT_FTPASCII* = OPT_TRANSFERTEXT
-  OPT_HEADERDATA* = OPT_WRITEHEADER
-  OPT_HTTPREQUEST* = - (1)
-  OPT_MUTE* = - (2)
-  OPT_PASSWDDATA* = - (4)
-  OPT_PASSWDFUNCTION* = - (3)
-  OPT_PASV_HOST* = - (9)
-  OPT_READDATA* = OPT_INFILE
-  OPT_SOURCE_HOST* = - (6)
-  OPT_SOURCE_PATH* = - (7)
-  OPT_SOURCE_PORT* = - (8)
-  OPTTYPE_FUNCTIONPOINT* = 20000
-  OPTTYPE_LONG* = 0
-  OPTTYPE_OBJECTPOINT* = 10000
-  OPTTYPE_OFF_T* = 30000
-  OPT_WRITEDATA* = OPT_FILE
-  POLL_IN* = 1
-  POLL_INOUT* = 3
-  POLL_NONE* = 0
-  POLL_OUT* = 2
-  POLL_REMOVE* = 4
-  READFUNC_ABORT* = 0x10000000
-  SOCKET_BAD* = - (1)
-  SOCKET_TIMEOUT* = SOCKET_BAD
-  VERSION_ASYNCHDNS* = 1 shl 7
-  VERSION_CONV* = 1 shl 12
-  VERSION_DEBUG* = 1 shl 6
-  VERSION_GSSNEGOTIATE* = 1 shl 5
-  VERSION_IDN* = 1 shl 10
-  VERSION_IPV6* = 1 shl 0
-  VERSION_KERBEROS4* = 1 shl 1
-  VERSION_LARGEFILE* = 1 shl 9
-  VERSION_LIBZ* = 1 shl 3
-  VERSION_NOW* = VERSION_THIRD
-  VERSION_NTLM* = 1 shl 4
-  VERSION_SPNEGO* = 1 shl 8
-  VERSION_SSL* = 1 shl 2
-  VERSION_SSPI* = 1 shl 11
-  FILE_OFFSET_BITS* = 0
-  FILESIZEBITS* = 0
-  FUNCTIONPOINT* = OPTTYPE_FUNCTIONPOINT
-  HTTPPOST_BUFFER* = 1 shl 4
-  HTTPPOST_FILENAME* = 1 shl 0
-  HTTPPOST_PTRBUFFER* = 1 shl 5
-  HTTPPOST_PTRCONTENTS* = 1 shl 3
-  HTTPPOST_PTRNAME* = 1 shl 2
-  HTTPPOST_READFILE* = 1 shl 1
-  LIBCURL_VERSION* = "7.15.5"
-  LIBCURL_VERSION_MAJOR* = 7
-  LIBCURL_VERSION_MINOR* = 15
-  LIBCURL_VERSION_NUM* = 0x00070F05
-  LIBCURL_VERSION_PATCH* = 5
-
-proc strequal*(s1, s2: cstring): int32{.cdecl, dynlib: libname, 
-                                        importc: "curl_strequal".}
-proc strnequal*(s1, s2: cstring, n: int): int32{.cdecl, dynlib: libname, 
-    importc: "curl_strnequal".}
-proc formadd*(httppost, last_post: PPcurl_httppost): FORMcode{.cdecl, varargs, 
-    dynlib: libname, importc: "curl_formadd".}
-proc formget*(form: Phttppost, arg: pointer, append: Formget_callback): int32{.
-    cdecl, dynlib: libname, importc: "curl_formget".}
-proc formfree*(form: Phttppost){.cdecl, dynlib: libname, 
-                                 importc: "curl_formfree".}
-proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_getenv".}
-proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
-proc easy_escape*(handle: PCurl, str: cstring, len: int32): cstring{.cdecl, 
-    dynlib: libname, importc: "curl_easy_escape".}
-proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_escape".}
-proc easy_unescape*(handle: PCurl, str: cstring, len: int32, outlength: var int32): cstring{.
-    cdecl, dynlib: libname, importc: "curl_easy_unescape".}
-proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_unescape".}
-proc free*(p: pointer){.cdecl, dynlib: libname, importc: "curl_free".}
-proc global_init*(flags: int32): Code{.cdecl, dynlib: libname, 
-                                        importc: "curl_global_init".}
-proc global_init_mem*(flags: int32, m: Malloc_callback, f: Free_callback, 
-                      r: Realloc_callback, s: Strdup_callback, 
-                      c: Calloc_callback): Code{.cdecl, dynlib: libname, 
-    importc: "curl_global_init_mem".}
-proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".}
-proc slist_append*(slist: Pslist, p: cstring): Pslist{.cdecl, dynlib: libname, 
-    importc: "curl_slist_append".}
-proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname, 
-                                     importc: "curl_slist_free_all".}
-proc getdate*(p: cstring, unused: ptr Time): Time{.cdecl, dynlib: libname, 
-    importc: "curl_getdate".}
-proc share_init*(): PSH{.cdecl, dynlib: libname, importc: "curl_share_init".}
-proc share_setopt*(para1: PSH, option: SHoption): SHcode{.cdecl, varargs, 
-    dynlib: libname, importc: "curl_share_setopt".}
-proc share_cleanup*(para1: PSH): SHcode{.cdecl, dynlib: libname, 
-    importc: "curl_share_cleanup".}
-proc version_info*(para1: Version): Pversion_info_data{.cdecl, dynlib: libname, 
-    importc: "curl_version_info".}
-proc easy_strerror*(para1: Code): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_easy_strerror".}
-proc share_strerror*(para1: SHcode): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_share_strerror".}
-proc easy_init*(): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_init".}
-proc easy_setopt*(curl: PCurl, option: Option): Code{.cdecl, varargs, dynlib: libname, 
-    importc: "curl_easy_setopt".}
-proc easy_perform*(curl: PCurl): Code{.cdecl, dynlib: libname, 
-                                importc: "curl_easy_perform".}
-proc easy_cleanup*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".}
-proc easy_getinfo*(curl: PCurl, info: INFO): Code{.cdecl, varargs, dynlib: libname, 
-    importc: "curl_easy_getinfo".}
-proc easy_duphandle*(curl: PCurl): PCurl{.cdecl, dynlib: libname, 
-                              importc: "curl_easy_duphandle".}
-proc easy_reset*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_reset".}
-proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".}
-proc multi_add_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl, 
-    dynlib: libname, importc: "curl_multi_add_handle".}
-proc multi_remove_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl, 
-    dynlib: libname, importc: "curl_multi_remove_handle".}
-proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set, 
-                  exc_fd_set: Pfd_set, max_fd: var int32): Mcode{.cdecl, 
-    dynlib: libname, importc: "curl_multi_fdset".}
-proc multi_perform*(multi_handle: PM, running_handles: var int32): Mcode{.
-    cdecl, dynlib: libname, importc: "curl_multi_perform".}
-proc multi_cleanup*(multi_handle: PM): Mcode{.cdecl, dynlib: libname, 
-    importc: "curl_multi_cleanup".}
-proc multi_info_read*(multi_handle: PM, msgs_in_queue: var int32): PMsg{.cdecl, 
-    dynlib: libname, importc: "curl_multi_info_read".}
-proc multi_strerror*(para1: Mcode): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_multi_strerror".}
-proc multi_socket*(multi_handle: PM, s: Socket, running_handles: var int32): Mcode{.
-    cdecl, dynlib: libname, importc: "curl_multi_socket".}
-proc multi_socket_all*(multi_handle: PM, running_handles: var int32): Mcode{.
-    cdecl, dynlib: libname, importc: "curl_multi_socket_all".}
-proc multi_timeout*(multi_handle: PM, milliseconds: var int32): Mcode{.cdecl, 
-    dynlib: libname, importc: "curl_multi_timeout".}
-proc multi_setopt*(multi_handle: PM, option: Moption): Mcode{.cdecl, varargs, 
-    dynlib: libname, importc: "curl_multi_setopt".}
-proc multi_assign*(multi_handle: PM, sockfd: Socket, sockp: pointer): Mcode{.
-    cdecl, dynlib: libname, importc: "curl_multi_assign".}
diff --git a/lib/wrappers/libffi/common/ffi.h b/lib/wrappers/libffi/common/ffi.h
deleted file mode 100644
index 07d650eac..000000000
--- a/lib/wrappers/libffi/common/ffi.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
-   libffi 2.00-beta - Copyright (c) 1996-2003  Red Hat, Inc.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-
-   ----------------------------------------------------------------------- */
-
-/* -------------------------------------------------------------------
-   The basic API is described in the README file.
-
-   The raw API is designed to bypass some of the argument packing
-   and unpacking on architectures for which it can be avoided.
-
-   The closure API allows interpreted functions to be packaged up
-   inside a C function pointer, so that they can be called as C functions,
-   with no understanding on the client side that they are interpreted.
-   It can also be used in other cases in which it is necessary to package
-   up a user specified parameter and a function pointer as a single
-   function pointer.
-
-   The closure API must be implemented in order to get its functionality,
-   e.g. for use by gij.  Routines are provided to emulate the raw API
-   if the underlying platform doesn't allow faster implementation.
-
-   More details on the raw and cloure API can be found in:
-
-   http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
-
-   and
-
-   http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
-   -------------------------------------------------------------------- */
-
-#ifndef LIBFFI_H
-#define LIBFFI_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Specify which architecture libffi is configured for. */
-//XXX #define X86
-
-/* ---- System configuration information --------------------------------- */
-
-#include <ffitarget.h>
-
-#ifndef LIBFFI_ASM
-
-#include <stddef.h>
-#include <limits.h>
-
-/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
-   But we can find it either under the correct ANSI name, or under GNU
-   C's internal name.  */
-#ifdef LONG_LONG_MAX
-# define FFI_LONG_LONG_MAX LONG_LONG_MAX
-#else
-# ifdef LLONG_MAX
-#  define FFI_LONG_LONG_MAX LLONG_MAX
-# else
-#  ifdef __GNUC__
-#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
-#  endif
-#  ifdef _MSC_VER
-#   define FFI_LONG_LONG_MAX _I64_MAX
-#  endif
-# endif
-#endif
-
-#if SCHAR_MAX == 127
-# define ffi_type_uchar                ffi_type_uint8
-# define ffi_type_schar                ffi_type_sint8
-#else
- #error "char size not supported"
-#endif
-
-#if SHRT_MAX == 32767
-# define ffi_type_ushort       ffi_type_uint16
-# define ffi_type_sshort       ffi_type_sint16
-#elif SHRT_MAX == 2147483647
-# define ffi_type_ushort       ffi_type_uint32
-# define ffi_type_sshort       ffi_type_sint32
-#else
- #error "short size not supported"
-#endif
-
-#if INT_MAX == 32767
-# define ffi_type_uint         ffi_type_uint16
-# define ffi_type_sint         ffi_type_sint16
-#elif INT_MAX == 2147483647
-# define ffi_type_uint         ffi_type_uint32
-# define ffi_type_sint         ffi_type_sint32
-#elif INT_MAX == 9223372036854775807
-# define ffi_type_uint         ffi_type_uint64
-# define ffi_type_sint         ffi_type_sint64
-#else
- #error "int size not supported"
-#endif
-
-#define ffi_type_ulong         ffi_type_uint64
-#define ffi_type_slong         ffi_type_sint64
-#if LONG_MAX == 2147483647
-# if FFI_LONG_LONG_MAX != 9223372036854775807
-  #error "no 64-bit data type supported"
-# endif
-#elif LONG_MAX != 9223372036854775807
- #error "long size not supported"
-#endif
-
-/* The closure code assumes that this works on pointers, i.e. a size_t	*/
-/* can hold a pointer.							*/
-
-typedef struct _ffi_type
-{
-  size_t size;
-  unsigned short alignment;
-  unsigned short type;
-  /*@null@*/ struct _ffi_type **elements;
-} ffi_type;
-
-/* These are defined in types.c */
-extern const ffi_type ffi_type_void;
-extern const ffi_type ffi_type_uint8;
-extern const ffi_type ffi_type_sint8;
-extern const ffi_type ffi_type_uint16;
-extern const ffi_type ffi_type_sint16;
-extern const ffi_type ffi_type_uint32;
-extern const ffi_type ffi_type_sint32;
-extern const ffi_type ffi_type_uint64;
-extern const ffi_type ffi_type_sint64;
-extern const ffi_type ffi_type_float;
-extern const ffi_type ffi_type_double;
-extern const ffi_type ffi_type_longdouble;
-extern const ffi_type ffi_type_pointer;
-
-
-typedef enum {
-  FFI_OK = 0,
-  FFI_BAD_TYPEDEF,
-  FFI_BAD_ABI 
-} ffi_status;
-
-typedef unsigned FFI_TYPE;
-
-typedef struct {
-  ffi_abi abi;
-  unsigned nargs;
-  /*@dependent@*/ ffi_type **arg_types;
-  /*@dependent@*/ ffi_type *rtype;
-  unsigned bytes;
-  unsigned flags;
-#ifdef FFI_EXTRA_CIF_FIELDS
-  FFI_EXTRA_CIF_FIELDS;
-#endif
-} ffi_cif;
-
-/* ---- Definitions for the raw API -------------------------------------- */
-
-#ifdef _WIN64
-#define FFI_SIZEOF_ARG 8
-#else
-#define FFI_SIZEOF_ARG 4
-#endif
-
-typedef union {
-  ffi_sarg  sint;
-  ffi_arg   uint;
-  float	    flt;
-  char      data[FFI_SIZEOF_ARG];
-  void*     ptr;
-} ffi_raw;
-
-void ffi_raw_call (/*@dependent@*/ ffi_cif *cif, 
-		   void (*fn)(), 
-		   /*@out@*/ void *rvalue, 
-		   /*@dependent@*/ ffi_raw *avalue);
-
-void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
-void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
-size_t ffi_raw_size (ffi_cif *cif);
-
-/* This is analogous to the raw API, except it uses Java parameter	*/
-/* packing, even on 64-bit machines.  I.e. on 64-bit machines		*/
-/* longs and doubles are followed by an empty 64-bit word.		*/
-
-void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif, 
-		        void (*fn)(), 
-		        /*@out@*/ void *rvalue, 
-		        /*@dependent@*/ ffi_raw *avalue);
-
-void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
-void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
-size_t ffi_java_raw_size (ffi_cif *cif);
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#if FFI_CLOSURES
-
-typedef struct {
-  char tramp[FFI_TRAMPOLINE_SIZE];
-  ffi_cif   *cif;
-  void     (*fun)(ffi_cif*,void*,void**,void*);
-  void      *user_data;
-} ffi_closure;
-
-void ffi_closure_free(void *);
-void *ffi_closure_alloc (size_t size, void **code);
-
-ffi_status
-ffi_prep_closure_loc (ffi_closure*,
-		  ffi_cif *,
-		  void (*fun)(ffi_cif*,void*,void**,void*),
-		  void *user_data,
-		  void *codeloc);
-
-typedef struct {
-  char tramp[FFI_TRAMPOLINE_SIZE];
-
-  ffi_cif   *cif;
-
-#if !FFI_NATIVE_RAW_API
-
-  /* if this is enabled, then a raw closure has the same layout 
-     as a regular closure.  We use this to install an intermediate 
-     handler to do the transaltion, void** -> ffi_raw*. */
-
-  void     (*translate_args)(ffi_cif*,void*,void**,void*);
-  void      *this_closure;
-
-#endif
-
-  void     (*fun)(ffi_cif*,void*,ffi_raw*,void*);
-  void      *user_data;
-
-} ffi_raw_closure;
-
-ffi_status
-ffi_prep_raw_closure (ffi_raw_closure*,
-		      ffi_cif *cif,
-		      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
-		      void *user_data);
-
-ffi_status
-ffi_prep_java_raw_closure (ffi_raw_closure*,
-		           ffi_cif *cif,
-		           void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
-		           void *user_data);
-
-#endif /* FFI_CLOSURES */
-
-/* ---- Public interface definition -------------------------------------- */
-
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, 
-			ffi_abi abi,
-			unsigned int nargs, 
-			/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, 
-			/*@dependent@*/ ffi_type **atypes);
-
-void
-ffi_call(/*@dependent@*/ ffi_cif *cif, 
-	 void (*fn)(), 
-	 /*@out@*/ void *rvalue, 
-	 /*@dependent@*/ void **avalue);
-
-/* Useful for eliminating compiler warnings */
-#define FFI_FN(f) ((void (*)())f)
-
-/* ---- Definitions shared with assembly code ---------------------------- */
-
-#endif
-
-/* If these change, update src/mips/ffitarget.h. */
-#define FFI_TYPE_VOID       0    
-#define FFI_TYPE_INT        1
-#define FFI_TYPE_FLOAT      2    
-#define FFI_TYPE_DOUBLE     3
-#if 1
-#define FFI_TYPE_LONGDOUBLE 4
-#else
-#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
-#endif
-#define FFI_TYPE_UINT8      5   
-#define FFI_TYPE_SINT8      6
-#define FFI_TYPE_UINT16     7 
-#define FFI_TYPE_SINT16     8
-#define FFI_TYPE_UINT32     9
-#define FFI_TYPE_SINT32     10
-#define FFI_TYPE_UINT64     11
-#define FFI_TYPE_SINT64     12
-#define FFI_TYPE_STRUCT     13
-#define FFI_TYPE_POINTER    14
-
-/* This should always refer to the last type code (for sanity checks) */
-#define FFI_TYPE_LAST       FFI_TYPE_POINTER
-
-#define FFI_HIDDEN /* no idea what the origial definition looks like ... */
-
-#ifdef __GNUC__
-#  define LIKELY(x) __builtin_expect(x, 1)
-#  define UNLIKELY(x) __builtin_expect(x, 0)
-#else
-#  define LIKELY(x) (x)
-#  define UNLIKELY(x) (x)
-#endif
-
-#define MAYBE_UNUSED
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/lib/wrappers/libffi/common/ffi_common.h b/lib/wrappers/libffi/common/ffi_common.h
deleted file mode 100644
index 43fb83b48..000000000
--- a/lib/wrappers/libffi/common/ffi_common.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi_common.h - Copyright (c) 1996  Red Hat, Inc.
-
-   Common internal definitions and macros. Only necessary for building
-   libffi.
-   ----------------------------------------------------------------------- */
-
-#ifndef FFI_COMMON_H
-#define FFI_COMMON_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <fficonfig.h>
-#include <malloc.h>
-
-/* Check for the existence of memcpy. */
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#if defined(FFI_DEBUG) 
-#include <stdio.h>
-#endif
-
-#ifdef FFI_DEBUG
-/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
-void ffi_stop_here(void);
-void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
-
-#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
-#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
-#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
-#else
-#define FFI_ASSERT(x) 
-#define FFI_ASSERT_AT(x, f, l)
-#define FFI_ASSERT_VALID_TYPE(x)
-#endif
-
-#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
-
-/* Extended cif, used in callback from assembly routine */
-typedef struct
-{
-  /*@dependent@*/ ffi_cif *cif;
-  /*@dependent@*/ void *rvalue;
-  /*@dependent@*/ void **avalue;
-} extended_cif;
-
-/* Terse sized type definitions.  */
-typedef unsigned int UINT8  __attribute__((__mode__(__QI__)));
-typedef signed int   SINT8  __attribute__((__mode__(__QI__)));
-typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
-typedef signed int   SINT16 __attribute__((__mode__(__HI__)));
-typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
-typedef signed int   SINT32 __attribute__((__mode__(__SI__)));
-typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
-typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
-
-typedef float FLOAT32;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/lib/wrappers/libffi/common/fficonfig.h b/lib/wrappers/libffi/common/fficonfig.h
deleted file mode 100644
index c14f653ec..000000000
--- a/lib/wrappers/libffi/common/fficonfig.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* fficonfig.h.  Originally created by configure, now hand_maintained for MSVC. */
-
-/* fficonfig.h.  Generated automatically by configure.  */
-/* fficonfig.h.in.  Generated automatically from configure.in by autoheader.  */
-
-/* Define this for MSVC, but not for mingw32! */
-#ifdef _MSC_VER
-#define __attribute__(x) /* */
-#endif
-#define alloca _alloca
-
-/*----------------------------------------------------------------*/
-
-/* Define if using alloca.c.  */
-/* #undef C_ALLOCA */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
-   This function is required for alloca.c support on those systems.  */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca, as a function or macro.  */
-#define HAVE_ALLOCA 1
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
-/* #define HAVE_ALLOCA_H 1 */
-
-/* If using the C implementation of alloca, define if you know the
-   direction of stack growth for your system; otherwise it will be
-   automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if you have the ANSI C header files.  */
-#define STDC_HEADERS 1
-
-/* Define if you have the memcpy function.  */
-#define HAVE_MEMCPY 1
-
-/* Define if read-only mmap of a plain file works. */
-//#define HAVE_MMAP_FILE 1
-
-/* Define if mmap of /dev/zero works. */
-//#define HAVE_MMAP_DEV_ZERO 1
-
-/* Define if mmap with MAP_ANON(YMOUS) works. */
-//#define HAVE_MMAP_ANON 1
-
-/* The number of bytes in type double */
-#define SIZEOF_DOUBLE 8
-
-/* The number of bytes in type long double */
-#define SIZEOF_LONG_DOUBLE 12
-
-/* Define if you have the long double type and it is bigger than a double */
-#define HAVE_LONG_DOUBLE 1
-
-/* whether byteorder is bigendian */
-/* #undef WORDS_BIGENDIAN */
-
-/* Define if the host machine stores words of multi-word integers in
-   big-endian order. */
-/* #undef HOST_WORDS_BIG_ENDIAN */
-
-/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
-#define BYTEORDER 1234
-
-/* Define if your assembler and linker support unaligned PC relative relocs. */
-/* #undef HAVE_AS_SPARC_UA_PCREL */
-
-/* Define if your assembler supports .register. */
-/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
-
-/* Define if .eh_frame sections should be read-only. */
-/* #undef HAVE_RO_EH_FRAME */
-
-/* Define to the flags needed for the .section .eh_frame directive. */
-/* #define EH_FRAME_FLAGS "aw" */
-
-/* Define to the flags needed for the .section .eh_frame directive. */
-/* #define EH_FRAME_FLAGS "aw" */
-
-/* Define this if you want extra debugging. */
-/* #undef FFI_DEBUG */
-
-/* Define this is you do not want support for aggregate types. */
-/* #undef FFI_NO_STRUCTS */
-
-/* Define this is you do not want support for the raw API. */
-/* #undef FFI_NO_RAW_API */
-
-/* Define this if you are using Purify and want to suppress spurious messages. */
-/* #undef USING_PURIFY */
-
diff --git a/lib/wrappers/libffi/common/ffitarget.h b/lib/wrappers/libffi/common/ffitarget.h
deleted file mode 100644
index d8d60f2e7..000000000
--- a/lib/wrappers/libffi/common/ffitarget.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
-   ffitarget.h - Copyright (c) 2012  Anthony Green
-                 Copyright (c) 1996-2003, 2010  Red Hat, Inc.
-                 Copyright (C) 2008  Free Software Foundation, Inc.
-
-   Target configuration macros for x86 and x86-64.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-
-   ----------------------------------------------------------------------- */
-
-#ifndef LIBFFI_TARGET_H
-#define LIBFFI_TARGET_H
-
-#ifndef LIBFFI_H
-#error "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
-#endif
-
-/* ---- System specific configurations ----------------------------------- */
-
-/* For code common to all platforms on x86 and x86_64. */
-#define X86_ANY
-
-#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
-#  if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64)
-#    define X86_64
-#    define X86_WIN64
-#  else
-#    define X86_32
-#    define X86_WIN32
-#  endif
-#endif
-
-#if defined (X86_64) && defined (__i386__)
-#undef X86_64
-#define X86
-#endif
-
-#ifdef X86_WIN64
-#define FFI_SIZEOF_ARG 8
-#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
-#endif
-
-/* ---- Generic type definitions ----------------------------------------- */
-
-#ifndef LIBFFI_ASM
-#ifdef X86_WIN64
-#ifdef _MSC_VER
-typedef unsigned __int64       ffi_arg;
-typedef __int64                ffi_sarg;
-#else
-typedef unsigned long long     ffi_arg;
-typedef long long              ffi_sarg;
-#endif
-#else
-#if defined __x86_64__ && defined __ILP32__
-#define FFI_SIZEOF_ARG 8
-#define FFI_SIZEOF_JAVA_RAW  4
-typedef unsigned long long     ffi_arg;
-typedef long long              ffi_sarg;
-#else
-typedef unsigned long          ffi_arg;
-typedef signed long            ffi_sarg;
-#endif
-#endif
-
-typedef enum ffi_abi {
-  FFI_FIRST_ABI = 0,
-
-  /* ---- Intel x86 Win32 ---------- */
-#ifdef X86_WIN32
-  FFI_SYSV,
-  FFI_STDCALL,
-  FFI_THISCALL,
-  FFI_FASTCALL,
-  FFI_MS_CDECL,
-  FFI_LAST_ABI,
-#ifdef _MSC_VER
-  FFI_DEFAULT_ABI = FFI_MS_CDECL
-#else
-  FFI_DEFAULT_ABI = FFI_SYSV
-#endif
-
-#elif defined(X86_WIN64)
-  FFI_WIN64,
-  FFI_LAST_ABI,
-  FFI_DEFAULT_ABI = FFI_WIN64
-
-#else
-  /* ---- Intel x86 and AMD x86-64 - */
-  FFI_SYSV,
-  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
-  FFI_LAST_ABI,
-#if defined(__i386__) || defined(__i386)
-  FFI_DEFAULT_ABI = FFI_SYSV
-#else
-  FFI_DEFAULT_ABI = FFI_UNIX64
-#endif
-#endif
-} ffi_abi;
-#endif
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#define FFI_CLOSURES 1
-#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
-#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
-#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
-#define FFI_TYPE_MS_STRUCT       (FFI_TYPE_LAST + 4)
-
-#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
-#define FFI_TRAMPOLINE_SIZE 24
-#define FFI_NATIVE_RAW_API 0
-#else
-#ifdef X86_WIN32
-#define FFI_TRAMPOLINE_SIZE 52
-#else
-#ifdef X86_WIN64
-#define FFI_TRAMPOLINE_SIZE 29
-#define FFI_NATIVE_RAW_API 0
-#define FFI_NO_RAW_API 1
-#else
-#define FFI_TRAMPOLINE_SIZE 10
-#endif
-#endif
-#ifndef X86_WIN64
-#define FFI_NATIVE_RAW_API 1	/* x86 has native raw api support */
-#endif
-#endif
-
-#endif
-
diff --git a/lib/wrappers/libffi/common/malloc_closure.c b/lib/wrappers/libffi/common/malloc_closure.c
deleted file mode 100644
index 5b33aa4ca..000000000
--- a/lib/wrappers/libffi/common/malloc_closure.c
+++ /dev/null
@@ -1,110 +0,0 @@
-#include <ffi.h>
-#ifdef MS_WIN32
-#include <windows.h>
-#else
-#include <sys/mman.h>
-#include <unistd.h>
-# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
-#  define MAP_ANONYMOUS MAP_ANON
-# endif
-#endif
-#include "ctypes.h"
-
-/* BLOCKSIZE can be adjusted.  Larger blocksize will take a larger memory
-   overhead, but allocate less blocks from the system.  It may be that some
-   systems have a limit of how many mmap'd blocks can be open.
-*/
-
-#define BLOCKSIZE _pagesize
-
-/* #define MALLOC_CLOSURE_DEBUG */ /* enable for some debugging output */
-
-/******************************************************************/
-
-typedef union _tagITEM {
-    ffi_closure closure;
-    union _tagITEM *next;
-} ITEM;
-
-static ITEM *free_list;
-static int _pagesize;
-
-static void more_core(void)
-{
-    ITEM *item;
-    int count, i;
-
-/* determine the pagesize */
-#ifdef MS_WIN32
-    if (!_pagesize) {
-        SYSTEM_INFO systeminfo;
-        GetSystemInfo(&systeminfo);
-        _pagesize = systeminfo.dwPageSize;
-    }
-#else
-    if (!_pagesize) {
-#ifdef _SC_PAGESIZE
-        _pagesize = sysconf(_SC_PAGESIZE);
-#else
-        _pagesize = getpagesize();
-#endif
-    }
-#endif
-
-    /* calculate the number of nodes to allocate */
-    count = BLOCKSIZE / sizeof(ITEM);
-
-    /* allocate a memory block */
-#ifdef MS_WIN32
-    item = (ITEM *)VirtualAlloc(NULL,
-                                           count * sizeof(ITEM),
-                                           MEM_COMMIT,
-                                           PAGE_EXECUTE_READWRITE);
-    if (item == NULL)
-        return;
-#else
-    item = (ITEM *)mmap(NULL,
-                        count * sizeof(ITEM),
-                        PROT_READ | PROT_WRITE | PROT_EXEC,
-                        MAP_PRIVATE | MAP_ANONYMOUS,
-                        -1,
-                        0);
-    if (item == (void *)MAP_FAILED)
-        return;
-#endif
-
-#ifdef MALLOC_CLOSURE_DEBUG
-    printf("block at %p allocated (%d bytes), %d ITEMs\n",
-           item, count * sizeof(ITEM), count);
-#endif
-    /* put them into the free list */
-    for (i = 0; i < count; ++i) {
-        item->next = free_list;
-        free_list = item;
-        ++item;
-    }
-}
-
-/******************************************************************/
-
-/* put the item back into the free list */
-void ffi_closure_free(void *p)
-{
-    ITEM *item = (ITEM *)p;
-    item->next = free_list;
-    free_list = item;
-}
-
-/* return one item from the free list, allocating more if needed */
-void *ffi_closure_alloc(size_t ignored, void** codeloc)
-{
-    ITEM *item;
-    if (!free_list)
-        more_core();
-    if (!free_list)
-        return NULL;
-    item = free_list;
-    free_list = item->next;
-    *codeloc = (void *)item;
-    return (void *)item;
-}
diff --git a/lib/wrappers/libffi/common/raw_api.c b/lib/wrappers/libffi/common/raw_api.c
deleted file mode 100644
index ce21372e2..000000000
--- a/lib/wrappers/libffi/common/raw_api.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* -----------------------------------------------------------------------
-   raw_api.c - Copyright (c) 1999, 2008  Red Hat, Inc.
-
-   Author: Kresten Krab Thorup <krab@gnu.org>
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-/* This file defines generic functions for use with the raw api. */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#if !FFI_NO_RAW_API
-
-size_t
-ffi_raw_size (ffi_cif *cif)
-{
-  size_t result = 0;
-  int i;
-
-  ffi_type **at = cif->arg_types;
-
-  for (i = cif->nargs-1; i >= 0; i--, at++)
-    {
-#if !FFI_NO_STRUCTS
-      if ((*at)->type == FFI_TYPE_STRUCT)
-	result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
-      else
-#endif
-	result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
-    }
-
-  return result;
-}
-
-
-void
-ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
-{
-  unsigned i;
-  ffi_type **tp = cif->arg_types;
-
-#if WORDS_BIGENDIAN
-
-  for (i = 0; i < cif->nargs; i++, tp++, args++)
-    {	  
-      switch ((*tp)->type)
-	{
-	case FFI_TYPE_UINT8:
-	case FFI_TYPE_SINT8:
-	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
-	  break;
-	  
-	case FFI_TYPE_UINT16:
-	case FFI_TYPE_SINT16:
-	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
-	  break;
-
-#if FFI_SIZEOF_ARG >= 4	  
-	case FFI_TYPE_UINT32:
-	case FFI_TYPE_SINT32:
-	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
-	  break;
-#endif
-	
-#if !FFI_NO_STRUCTS  
-	case FFI_TYPE_STRUCT:
-	  *args = (raw++)->ptr;
-	  break;
-#endif
-
-	case FFI_TYPE_POINTER:
-	  *args = (void*) &(raw++)->ptr;
-	  break;
-	  
-	default:
-	  *args = raw;
-	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
-	}
-    }
-
-#else /* WORDS_BIGENDIAN */
-
-#if !PDP
-
-  /* then assume little endian */
-  for (i = 0; i < cif->nargs; i++, tp++, args++)
-    {	  
-#if !FFI_NO_STRUCTS
-      if ((*tp)->type == FFI_TYPE_STRUCT)
-	{
-	  *args = (raw++)->ptr;
-	}
-      else
-#endif
-	{
-	  *args = (void*) raw;
-	  raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
-	}
-    }
-
-#else
-#error "pdp endian not supported"
-#endif /* ! PDP */
-
-#endif /* WORDS_BIGENDIAN */
-}
-
-void
-ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
-{
-  unsigned i;
-  ffi_type **tp = cif->arg_types;
-
-  for (i = 0; i < cif->nargs; i++, tp++, args++)
-    {	  
-      switch ((*tp)->type)
-	{
-	case FFI_TYPE_UINT8:
-	  (raw++)->uint = *(UINT8*) (*args);
-	  break;
-
-	case FFI_TYPE_SINT8:
-	  (raw++)->sint = *(SINT8*) (*args);
-	  break;
-
-	case FFI_TYPE_UINT16:
-	  (raw++)->uint = *(UINT16*) (*args);
-	  break;
-
-	case FFI_TYPE_SINT16:
-	  (raw++)->sint = *(SINT16*) (*args);
-	  break;
-
-#if FFI_SIZEOF_ARG >= 4
-	case FFI_TYPE_UINT32:
-	  (raw++)->uint = *(UINT32*) (*args);
-	  break;
-
-	case FFI_TYPE_SINT32:
-	  (raw++)->sint = *(SINT32*) (*args);
-	  break;
-#endif
-
-#if !FFI_NO_STRUCTS
-	case FFI_TYPE_STRUCT:
-	  (raw++)->ptr = *args;
-	  break;
-#endif
-
-	case FFI_TYPE_POINTER:
-	  (raw++)->ptr = **(void***) args;
-	  break;
-
-	default:
-	  memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
-	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
-	}
-    }
-}
-
-#if !FFI_NATIVE_RAW_API
-
-
-/* This is a generic definition of ffi_raw_call, to be used if the
- * native system does not provide a machine-specific implementation.
- * Having this, allows code to be written for the raw API, without
- * the need for system-specific code to handle input in that format;
- * these following couple of functions will handle the translation forth
- * and back automatically. */
-
-void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw)
-{
-  void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
-  ffi_raw_to_ptrarray (cif, raw, avalue);
-  ffi_call (cif, fn, rvalue, avalue);
-}
-
-#if FFI_CLOSURES		/* base system provides closures */
-
-static void
-ffi_translate_args (ffi_cif *cif, void *rvalue,
-		    void **avalue, void *user_data)
-{
-  ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif));
-  ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
-
-  ffi_ptrarray_to_raw (cif, avalue, raw);
-  (*cl->fun) (cif, rvalue, raw, cl->user_data);
-}
-
-ffi_status
-ffi_prep_raw_closure_loc (ffi_raw_closure* cl,
-			  ffi_cif *cif,
-			  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
-			  void *user_data,
-			  void *codeloc)
-{
-  ffi_status status;
-
-  status = ffi_prep_closure_loc ((ffi_closure*) cl,
-				 cif,
-				 &ffi_translate_args,
-				 codeloc,
-				 codeloc);
-  if (status == FFI_OK)
-    {
-      cl->fun       = fun;
-      cl->user_data = user_data;
-    }
-
-  return status;
-}
-
-#endif /* FFI_CLOSURES */
-#endif /* !FFI_NATIVE_RAW_API */
-
-#if FFI_CLOSURES
-
-/* Again, here is the generic version of ffi_prep_raw_closure, which
- * will install an intermediate "hub" for translation of arguments from
- * the pointer-array format, to the raw format */
-
-ffi_status
-ffi_prep_raw_closure (ffi_raw_closure* cl,
-		      ffi_cif *cif,
-		      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
-		      void *user_data)
-{
-  return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl);
-}
-
-#endif /* FFI_CLOSURES */
-
-#endif /* !FFI_NO_RAW_API */
diff --git a/lib/wrappers/libffi/gcc/closures.c b/lib/wrappers/libffi/gcc/closures.c
deleted file mode 100644
index c0ee06891..000000000
--- a/lib/wrappers/libffi/gcc/closures.c
+++ /dev/null
@@ -1,627 +0,0 @@
-/* -----------------------------------------------------------------------
-   closures.c - Copyright (c) 2007, 2009, 2010  Red Hat, Inc.
-                Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc
-                Copyright (c) 2011 Plausible Labs Cooperative, Inc.
-
-   Code to allocate and deallocate memory for closures.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#if defined __linux__ && !defined _GNU_SOURCE
-#define _GNU_SOURCE 1
-#endif
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
-# if __gnu_linux__
-/* This macro indicates it may be forbidden to map anonymous memory
-   with both write and execute permission.  Code compiled when this
-   option is defined will attempt to map such pages once, but if it
-   fails, it falls back to creating a temporary file in a writable and
-   executable filesystem and mapping pages from it into separate
-   locations in the virtual memory space, one location writable and
-   another executable.  */
-#  define FFI_MMAP_EXEC_WRIT 1
-#  define HAVE_MNTENT 1
-# endif
-# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
-/* Windows systems may have Data Execution Protection (DEP) enabled, 
-   which requires the use of VirtualMalloc/VirtualFree to alloc/free
-   executable memory. */
-#  define FFI_MMAP_EXEC_WRIT 1
-# endif
-#endif
-
-#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
-# ifdef __linux__
-/* When defined to 1 check for SELinux and if SELinux is active,
-   don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that
-   might cause audit messages.  */
-#  define FFI_MMAP_EXEC_SELINUX 1
-# endif
-#endif
-
-#if FFI_CLOSURES
-
-# if FFI_EXEC_TRAMPOLINE_TABLE
-
-// Per-target implementation; It's unclear what can reasonable be shared
-// between two OS/architecture implementations.
-
-# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */
-
-#define USE_LOCKS 1
-#define USE_DL_PREFIX 1
-#ifdef __GNUC__
-#ifndef USE_BUILTIN_FFS
-#define USE_BUILTIN_FFS 1
-#endif
-#endif
-
-/* We need to use mmap, not sbrk.  */
-#define HAVE_MORECORE 0
-
-/* We could, in theory, support mremap, but it wouldn't buy us anything.  */
-#define HAVE_MREMAP 0
-
-/* We have no use for this, so save some code and data.  */
-#define NO_MALLINFO 1
-
-/* We need all allocations to be in regular segments, otherwise we
-   lose track of the corresponding code address.  */
-#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
-
-/* Don't allocate more than a page unless needed.  */
-#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize)
-
-#if FFI_CLOSURE_TEST
-/* Don't release single pages, to avoid a worst-case scenario of
-   continuously allocating and releasing single pages, but release
-   pairs of pages, which should do just as well given that allocations
-   are likely to be small.  */
-#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize)
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <stdio.h>
-#if !defined(X86_WIN32) && !defined(X86_WIN64)
-#ifdef HAVE_MNTENT
-#include <mntent.h>
-#endif /* HAVE_MNTENT */
-#include <sys/param.h>
-#include <pthread.h>
-
-/* We don't want sys/mman.h to be included after we redefine mmap and
-   dlmunmap.  */
-#include <sys/mman.h>
-#define LACKS_SYS_MMAN_H 1
-
-#if FFI_MMAP_EXEC_SELINUX
-#include <sys/statfs.h>
-#include <stdlib.h>
-
-static int selinux_enabled = -1;
-
-static int
-selinux_enabled_check (void)
-{
-  struct statfs sfs;
-  FILE *f;
-  char *buf = NULL;
-  size_t len = 0;
-
-  if (statfs ("/selinux", &sfs) >= 0
-      && (unsigned int) sfs.f_type == 0xf97cff8cU)
-    return 1;
-  f = fopen ("/proc/mounts", "r");
-  if (f == NULL)
-    return 0;
-  while (getline (&buf, &len, f) >= 0)
-    {
-      char *p = strchr (buf, ' ');
-      if (p == NULL)
-        break;
-      p = strchr (p + 1, ' ');
-      if (p == NULL)
-        break;
-      if (strncmp (p + 1, "selinuxfs ", 10) == 0)
-        {
-          free (buf);
-          fclose (f);
-          return 1;
-        }
-    }
-  free (buf);
-  fclose (f);
-  return 0;
-}
-
-#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \
-			      : (selinux_enabled = selinux_enabled_check ()))
-
-#else
-
-#define is_selinux_enabled() 0
-
-#endif /* !FFI_MMAP_EXEC_SELINUX */
-
-/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
-#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
-#include <stdlib.h>
-
-static int emutramp_enabled = -1;
-
-static int
-emutramp_enabled_check (void)
-{
-  if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
-    return 1;
-  else
-    return 0;
-}
-
-#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
-                               : (emutramp_enabled = emutramp_enabled_check ()))
-#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
-
-#elif defined (__CYGWIN__) || defined(__INTERIX)
-
-#include <sys/mman.h>
-
-/* Cygwin is Linux-like, but not quite that Linux-like.  */
-#define is_selinux_enabled() 0
-
-#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
-
-#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
-#define is_emutramp_enabled() 0
-#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
-
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
-/* Use these for mmap and munmap within dlmalloc.c.  */
-static void *dlmmap(void *, size_t, int, int, int, off_t);
-static int dlmunmap(void *, size_t);
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
-
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
-
-/* A mutex used to synchronize access to *exec* variables in this file.  */
-static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* A file descriptor of a temporary file from which we'll map
-   executable pages.  */
-static int execfd = -1;
-
-/* The amount of space already allocated from the temporary file.  */
-static size_t execsize = 0;
-
-/* Open a temporary file name, and immediately unlink it.  */
-static int
-open_temp_exec_file_name (char *name)
-{
-  int fd = mkstemp (name);
-
-  if (fd != -1)
-    unlink (name);
-
-  return fd;
-}
-
-/* Open a temporary file in the named directory.  */
-static int
-open_temp_exec_file_dir (const char *dir)
-{
-  static const char suffix[] = "/ffiXXXXXX";
-  int lendir = strlen (dir);
-  char *tempname = __builtin_alloca (lendir + sizeof (suffix));
-
-  if (!tempname)
-    return -1;
-
-  memcpy (tempname, dir, lendir);
-  memcpy (tempname + lendir, suffix, sizeof (suffix));
-
-  return open_temp_exec_file_name (tempname);
-}
-
-/* Open a temporary file in the directory in the named environment
-   variable.  */
-static int
-open_temp_exec_file_env (const char *envvar)
-{
-  const char *value = getenv (envvar);
-
-  if (!value)
-    return -1;
-
-  return open_temp_exec_file_dir (value);
-}
-
-#ifdef HAVE_MNTENT
-/* Open a temporary file in an executable and writable mount point
-   listed in the mounts file.  Subsequent calls with the same mounts
-   keep searching for mount points in the same file.  Providing NULL
-   as the mounts file closes the file.  */
-static int
-open_temp_exec_file_mnt (const char *mounts)
-{
-  static const char *last_mounts;
-  static FILE *last_mntent;
-
-  if (mounts != last_mounts)
-    {
-      if (last_mntent)
-	endmntent (last_mntent);
-
-      last_mounts = mounts;
-
-      if (mounts)
-	last_mntent = setmntent (mounts, "r");
-      else
-	last_mntent = NULL;
-    }
-
-  if (!last_mntent)
-    return -1;
-
-  for (;;)
-    {
-      int fd;
-      struct mntent mnt;
-      char buf[MAXPATHLEN * 3];
-
-      if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
-	return -1;
-
-      if (hasmntopt (&mnt, "ro")
-	  || hasmntopt (&mnt, "noexec")
-	  || access (mnt.mnt_dir, W_OK))
-	continue;
-
-      fd = open_temp_exec_file_dir (mnt.mnt_dir);
-
-      if (fd != -1)
-	return fd;
-    }
-}
-#endif /* HAVE_MNTENT */
-
-/* Instructions to look for a location to hold a temporary file that
-   can be mapped in for execution.  */
-static struct
-{
-  int (*func)(const char *);
-  const char *arg;
-  int repeat;
-} open_temp_exec_file_opts[] = {
-  { open_temp_exec_file_env, "TMPDIR", 0 },
-  { open_temp_exec_file_dir, "/tmp", 0 },
-  { open_temp_exec_file_dir, "/var/tmp", 0 },
-  { open_temp_exec_file_dir, "/dev/shm", 0 },
-  { open_temp_exec_file_env, "HOME", 0 },
-#ifdef HAVE_MNTENT
-  { open_temp_exec_file_mnt, "/etc/mtab", 1 },
-  { open_temp_exec_file_mnt, "/proc/mounts", 1 },
-#endif /* HAVE_MNTENT */
-};
-
-/* Current index into open_temp_exec_file_opts.  */
-static int open_temp_exec_file_opts_idx = 0;
-
-/* Reset a current multi-call func, then advances to the next entry.
-   If we're at the last, go back to the first and return nonzero,
-   otherwise return zero.  */
-static int
-open_temp_exec_file_opts_next (void)
-{
-  if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
-    open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL);
-
-  open_temp_exec_file_opts_idx++;
-  if (open_temp_exec_file_opts_idx
-      == (sizeof (open_temp_exec_file_opts)
-	  / sizeof (*open_temp_exec_file_opts)))
-    {
-      open_temp_exec_file_opts_idx = 0;
-      return 1;
-    }
-
-  return 0;
-}
-
-/* Return a file descriptor of a temporary zero-sized file in a
-   writable and exexutable filesystem.  */
-static int
-open_temp_exec_file (void)
-{
-  int fd;
-
-  do
-    {
-      fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func
-	(open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg);
-
-      if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat
-	  || fd == -1)
-	{
-	  if (open_temp_exec_file_opts_next ())
-	    break;
-	}
-    }
-  while (fd == -1);
-
-  return fd;
-}
-
-/* Map in a chunk of memory from the temporary exec file into separate
-   locations in the virtual memory address space, one writable and one
-   executable.  Returns the address of the writable portion, after
-   storing an offset to the corresponding executable portion at the
-   last word of the requested chunk.  */
-static void *
-dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
-{
-  void *ptr;
-
-  if (execfd == -1)
-    {
-      open_temp_exec_file_opts_idx = 0;
-    retry_open:
-      execfd = open_temp_exec_file ();
-      if (execfd == -1)
-	return MFAIL;
-    }
-
-  offset = execsize;
-
-  if (ftruncate (execfd, offset + length))
-    return MFAIL;
-
-  flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
-  flags |= MAP_SHARED;
-
-  ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC,
-	      flags, execfd, offset);
-  if (ptr == MFAIL)
-    {
-      if (!offset)
-	{
-	  close (execfd);
-	  goto retry_open;
-	}
-      ftruncate (execfd, offset);
-      return MFAIL;
-    }
-  else if (!offset
-	   && open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
-    open_temp_exec_file_opts_next ();
-
-  start = mmap (start, length, prot, flags, execfd, offset);
-
-  if (start == MFAIL)
-    {
-      munmap (ptr, length);
-      ftruncate (execfd, offset);
-      return start;
-    }
-
-  mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
-
-  execsize += length;
-
-  return start;
-}
-
-/* Map in a writable and executable chunk of memory if possible.
-   Failing that, fall back to dlmmap_locked.  */
-static void *
-dlmmap (void *start, size_t length, int prot,
-	int flags, int fd, off_t offset)
-{
-  void *ptr;
-
-  assert (start == NULL && length % malloc_getpagesize == 0
-	  && prot == (PROT_READ | PROT_WRITE)
-	  && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
-	  && fd == -1 && offset == 0);
-
-#if FFI_CLOSURE_TEST
-  printf ("mapping in %zi\n", length);
-#endif
-
-  if (execfd == -1 && is_emutramp_enabled ())
-    {
-      ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
-      return ptr;
-    }
-
-  if (execfd == -1 && !is_selinux_enabled ())
-    {
-      ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
-
-      if (ptr != MFAIL || (errno != EPERM && errno != EACCES))
-	/* Cool, no need to mess with separate segments.  */
-	return ptr;
-
-      /* If MREMAP_DUP is ever introduced and implemented, try mmap
-	 with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
-	 MREMAP_DUP and prot at this point.  */
-    }
-
-  if (execsize == 0 || execfd == -1)
-    {
-      pthread_mutex_lock (&open_temp_exec_file_mutex);
-      ptr = dlmmap_locked (start, length, prot, flags, offset);
-      pthread_mutex_unlock (&open_temp_exec_file_mutex);
-
-      return ptr;
-    }
-
-  return dlmmap_locked (start, length, prot, flags, offset);
-}
-
-/* Release memory at the given address, as well as the corresponding
-   executable page if it's separate.  */
-static int
-dlmunmap (void *start, size_t length)
-{
-  /* We don't bother decreasing execsize or truncating the file, since
-     we can't quite tell whether we're unmapping the end of the file.
-     We don't expect frequent deallocation anyway.  If we did, we
-     could locate pages in the file by writing to the pages being
-     deallocated and checking that the file contents change.
-     Yuck.  */
-  msegmentptr seg = segment_holding (gm, start);
-  void *code;
-
-#if FFI_CLOSURE_TEST
-  printf ("unmapping %zi\n", length);
-#endif
-
-  if (seg && (code = add_segment_exec_offset (start, seg)) != start)
-    {
-      int ret = munmap (code, length);
-      if (ret)
-	return ret;
-    }
-
-  return munmap (start, length);
-}
-
-#if FFI_CLOSURE_FREE_CODE
-/* Return segment holding given code address.  */
-static msegmentptr
-segment_holding_code (mstate m, char* addr)
-{
-  msegmentptr sp = &m->seg;
-  for (;;) {
-    if (addr >= add_segment_exec_offset (sp->base, sp)
-	&& addr < add_segment_exec_offset (sp->base, sp) + sp->size)
-      return sp;
-    if ((sp = sp->next) == 0)
-      return 0;
-  }
-}
-#endif
-
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
-
-/* Allocate a chunk of memory with the given size.  Returns a pointer
-   to the writable address, and sets *CODE to the executable
-   corresponding virtual address.  */
-void *
-ffi_closure_alloc (size_t size, void **code)
-{
-  *code = malloc(size);
-  return *code;
-#if 0
-  void *ptr;
-
-  if (!code)
-    return NULL;
-
-  ptr = dlmalloc (size);
-
-  if (ptr)
-    {
-      msegmentptr seg = segment_holding (gm, ptr);
-
-      *code = add_segment_exec_offset (ptr, seg);
-    }
-
-  return ptr;
-#endif
-}
-
-/* Release a chunk of memory allocated with ffi_closure_alloc.  If
-   FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
-   writable or the executable address given.  Otherwise, only the
-   writable address can be provided here.  */
-void
-ffi_closure_free (void *ptr)
-{
-#if 0
-#if FFI_CLOSURE_FREE_CODE
-  msegmentptr seg = segment_holding_code(gm, ptr);
-
-  if (seg)
-    ptr = sub_segment_exec_offset(ptr, seg);
-#endif
-
-  dlfree(ptr);
-#endif
-  free(ptr);
-}
-
-
-#if FFI_CLOSURE_TEST
-/* Do some internal sanity testing to make sure allocation and
-   deallocation of pages are working as intended.  */
-int main ()
-{
-  void *p[3];
-#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0)
-#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0)
-  GET (0, malloc_getpagesize / 2);
-  GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*));
-  PUT (1);
-  GET (1, 2 * malloc_getpagesize);
-  GET (2, malloc_getpagesize / 2);
-  PUT (1);
-  PUT (0);
-  PUT (2);
-  return 0;
-}
-#endif /* FFI_CLOSURE_TEST */
-# else /* ! FFI_MMAP_EXEC_WRIT */
-
-/* On many systems, memory returned by malloc is writable and
-   executable, so just use it.  */
-
-#include <stdlib.h>
-
-void *
-ffi_closure_alloc (size_t size, void **code)
-{
-  if (!code)
-    return NULL;
-
-  return *code = malloc (size);
-}
-
-void
-ffi_closure_free (void *ptr)
-{
-  free (ptr);
-}
-
-# endif /* ! FFI_MMAP_EXEC_WRIT */
-#endif /* FFI_CLOSURES */
diff --git a/lib/wrappers/libffi/gcc/ffi.c b/lib/wrappers/libffi/gcc/ffi.c
deleted file mode 100644
index 0600414d4..000000000
--- a/lib/wrappers/libffi/gcc/ffi.c
+++ /dev/null
@@ -1,841 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008  Red Hat, Inc.
-           Copyright (c) 2002  Ranjit Mathew
-           Copyright (c) 2002  Bo Thorsen
-           Copyright (c) 2002  Roger Sayle
-           Copyright (C) 2008, 2010  Free Software Foundation, Inc.
-
-   x86 Foreign Function Interface
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#if !defined(__x86_64__) || defined(_WIN64)
-
-#ifdef _WIN64
-#include <windows.h>
-#endif
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-
-/* ffi_prep_args is called by the assembly routine once stack space
-   has been allocated for the function's arguments */
-
-void ffi_prep_args(char *stack, extended_cif *ecif)
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-#ifdef X86_WIN32
-  size_t p_stack_args[2];
-  void *p_stack_data[2];
-  char *argp2 = stack;
-  int stack_args_count = 0;
-  int cabi = ecif->cif->abi;
-#endif
-
-  argp = stack;
-
-  if ((ecif->cif->flags == FFI_TYPE_STRUCT
-       || ecif->cif->flags == FFI_TYPE_MS_STRUCT)
-#ifdef X86_WIN64
-      && (ecif->cif->rtype->size != 1 && ecif->cif->rtype->size != 2
-          && ecif->cif->rtype->size != 4 && ecif->cif->rtype->size != 8)
-#endif
-      )
-    {
-      *(void **) argp = ecif->rvalue;
-#ifdef X86_WIN32
-      /* For fastcall/thiscall this is first register-passed
-         argument.  */
-      if (cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
-	{
-	  p_stack_args[stack_args_count] = sizeof (void*);
-	  p_stack_data[stack_args_count] = argp;
-	  ++stack_args_count;
-	}
-#endif
-      argp += sizeof(void*);
-    }
-
-  p_argv = ecif->avalue;
-
-  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
-       i != 0;
-       i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(void*) - 1) & (size_t) argp)
-        argp = (char *) ALIGN(argp, sizeof(void*));
-
-      z = (*p_arg)->size;
-#ifdef X86_WIN64
-      if (z > sizeof(ffi_arg)
-          || ((*p_arg)->type == FFI_TYPE_STRUCT
-              && (z != 1 && z != 2 && z != 4 && z != 8))
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
-          || ((*p_arg)->type == FFI_TYPE_LONGDOUBLE)
-#endif
-          )
-        {
-          z = sizeof(ffi_arg);
-          *(void **)argp = *p_argv;
-        }
-      else if ((*p_arg)->type == FFI_TYPE_FLOAT)
-        {
-          memcpy(argp, *p_argv, z);
-        }
-      else
-#endif
-      if (z < sizeof(ffi_arg))
-        {
-          z = sizeof(ffi_arg);
-          switch ((*p_arg)->type)
-            {
-            case FFI_TYPE_SINT8:
-              *(ffi_sarg *) argp = (ffi_sarg)*(SINT8 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_UINT8:
-              *(ffi_arg *) argp = (ffi_arg)*(UINT8 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_SINT16:
-              *(ffi_sarg *) argp = (ffi_sarg)*(SINT16 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_UINT16:
-              *(ffi_arg *) argp = (ffi_arg)*(UINT16 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_SINT32:
-              *(ffi_sarg *) argp = (ffi_sarg)*(SINT32 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_UINT32:
-              *(ffi_arg *) argp = (ffi_arg)*(UINT32 *)(* p_argv);
-              break;
-
-            case FFI_TYPE_STRUCT:
-              *(ffi_arg *) argp = *(ffi_arg *)(* p_argv);
-              break;
-
-            default:
-              FFI_ASSERT(0);
-            }
-        }
-      else
-        {
-          memcpy(argp, *p_argv, z);
-        }
-
-#ifdef X86_WIN32
-    /* For thiscall/fastcall convention register-passed arguments
-       are the first two none-floating-point arguments with a size
-       smaller or equal to sizeof (void*).  */
-    if ((cabi == FFI_THISCALL && stack_args_count < 1)
-        || (cabi == FFI_FASTCALL && stack_args_count < 2))
-      {
-	if (z <= 4
-	    && ((*p_arg)->type != FFI_TYPE_FLOAT
-	        && (*p_arg)->type != FFI_TYPE_STRUCT))
-	  {
-	    p_stack_args[stack_args_count] = z;
-	    p_stack_data[stack_args_count] = argp;
-	    ++stack_args_count;
-	  }
-      }
-#endif
-      p_argv++;
-#ifdef X86_WIN64
-      argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
-#else
-      argp += z;
-#endif
-    }
-
-#ifdef X86_WIN32
-  /* We need to move the register-passed arguments for thiscall/fastcall
-     on top of stack, so that those can be moved to registers ecx/edx by
-     call-handler.  */
-  if (stack_args_count > 0)
-    {
-      size_t zz = (p_stack_args[0] + 3) & ~3;
-      char *h;
-
-      /* Move first argument to top-stack position.  */
-      if (p_stack_data[0] != argp2)
-	{
-	  h = alloca (zz + 1);
-	  memcpy (h, p_stack_data[0], zz);
-	  memmove (argp2 + zz, argp2,
-	           (size_t) ((char *) p_stack_data[0] - (char*)argp2));
-	  memcpy (argp2, h, zz);
-	}
-
-      argp2 += zz;
-      --stack_args_count;
-      if (zz > 4)
-	stack_args_count = 0;
-
-      /* If we have a second argument, then move it on top
-         after the first one.  */
-      if (stack_args_count > 0 && p_stack_data[1] != argp2)
-	{
-	  zz = p_stack_args[1];
-	  zz = (zz + 3) & ~3;
-	  h = alloca (zz + 1);
-	  h = alloca (zz + 1);
-	  memcpy (h, p_stack_data[1], zz);
-	  memmove (argp2 + zz, argp2, (size_t) ((char*) p_stack_data[1] - (char*)argp2));
-	  memcpy (argp2, h, zz);
-	}
-    }
-#endif
-  return;
-}
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
-{
-  unsigned int i;
-  ffi_type **ptr;
-
-  /* Set the return type flag */
-  switch (cif->rtype->type)
-    {
-    case FFI_TYPE_VOID:
-    case FFI_TYPE_UINT8:
-    case FFI_TYPE_UINT16:
-    case FFI_TYPE_SINT8:
-    case FFI_TYPE_SINT16:
-#ifdef X86_WIN64
-    case FFI_TYPE_UINT32:
-    case FFI_TYPE_SINT32:
-#endif
-    case FFI_TYPE_SINT64:
-    case FFI_TYPE_FLOAT:
-    case FFI_TYPE_DOUBLE:
-#ifndef X86_WIN64
-#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
-    case FFI_TYPE_LONGDOUBLE:
-#endif
-#endif
-      cif->flags = (unsigned) cif->rtype->type;
-      break;
-
-    case FFI_TYPE_UINT64:
-#ifdef X86_WIN64
-    case FFI_TYPE_POINTER:
-#endif
-      cif->flags = FFI_TYPE_SINT64;
-      break;
-
-    case FFI_TYPE_STRUCT:
-#ifndef X86
-      if (cif->rtype->size == 1)
-        {
-          cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
-        }
-      else if (cif->rtype->size == 2)
-        {
-          cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
-        }
-      else if (cif->rtype->size == 4)
-        {
-#ifdef X86_WIN64
-          cif->flags = FFI_TYPE_SMALL_STRUCT_4B;
-#else
-          cif->flags = FFI_TYPE_INT; /* same as int type */
-#endif
-        }
-      else if (cif->rtype->size == 8)
-        {
-          cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
-        }
-      else
-#endif
-        {
-#ifdef X86_WIN32
-          if (cif->abi == FFI_MS_CDECL)
-            cif->flags = FFI_TYPE_MS_STRUCT;
-          else
-#endif
-            cif->flags = FFI_TYPE_STRUCT;
-          /* allocate space for return value pointer */
-          cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
-        }
-      break;
-
-    default:
-#ifdef X86_WIN64
-      cif->flags = FFI_TYPE_SINT64;
-      break;
-    case FFI_TYPE_INT:
-      cif->flags = FFI_TYPE_SINT32;
-#else
-      cif->flags = FFI_TYPE_INT;
-#endif
-      break;
-    }
-
-  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
-    {
-      if (((*ptr)->alignment - 1) & cif->bytes)
-        cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
-      cif->bytes += ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
-    }
-
-#ifdef X86_WIN64
-  /* ensure space for storing four registers */
-  cif->bytes += 4 * sizeof(ffi_arg);
-#endif
-
-  cif->bytes = (cif->bytes + 15) & ~0xF;
-
-  return FFI_OK;
-}
-
-#ifdef X86_WIN64
-extern int
-ffi_call_win64(void (*)(char *, extended_cif *), extended_cif *,
-               unsigned, unsigned, unsigned *, void (*fn)(void));
-#elif defined(X86_WIN32)
-extern void
-ffi_call_win32(void (*)(char *, extended_cif *), extended_cif *,
-               unsigned, unsigned, unsigned, unsigned *, void (*fn)(void));
-#else
-extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
-                          unsigned, unsigned, unsigned *, void (*fn)(void));
-#endif
-
-void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
-{
-  extended_cif ecif;
-
-  ecif.cif = cif;
-  ecif.avalue = avalue;
-  
-  /* If the return value is a struct and we don't have a return */
-  /* value address then we need to make one                     */
-
-#ifdef X86_WIN64
-  if (rvalue == NULL
-      && cif->flags == FFI_TYPE_STRUCT
-      && cif->rtype->size != 1 && cif->rtype->size != 2
-      && cif->rtype->size != 4 && cif->rtype->size != 8)
-    {
-      ecif.rvalue = alloca((cif->rtype->size + 0xF) & ~0xF);
-    }
-#else
-  if (rvalue == NULL
-      && (cif->flags == FFI_TYPE_STRUCT
-          || cif->flags == FFI_TYPE_MS_STRUCT))
-    {
-      ecif.rvalue = alloca(cif->rtype->size);
-    }
-#endif
-  else
-    ecif.rvalue = rvalue;
-    
-  
-  switch (cif->abi) 
-    {
-#ifdef X86_WIN64
-    case FFI_WIN64:
-      ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
-                     cif->flags, ecif.rvalue, fn);
-      break;
-#elif defined(X86_WIN32)
-    case FFI_SYSV:
-    case FFI_STDCALL:
-    case FFI_MS_CDECL:
-      ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags,
-		     ecif.rvalue, fn);
-      break;
-    case FFI_THISCALL:
-    case FFI_FASTCALL:
-      {
-	unsigned int abi = cif->abi;
-	unsigned int i, passed_regs = 0;
-
-	if (cif->flags == FFI_TYPE_STRUCT)
-	  ++passed_regs;
-
-	for (i=0; i < cif->nargs && passed_regs < 2;i++)
-	  {
-	    size_t sz;
-
-	    if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
-	        || cif->arg_types[i]->type == FFI_TYPE_STRUCT)
-	      continue;
-	    sz = (cif->arg_types[i]->size + 3) & ~3;
-	    if (sz == 0 || sz > 4)
-	      continue;
-	    ++passed_regs;
-	  }
-	if (passed_regs < 2 && abi == FFI_FASTCALL)
-	  abi = FFI_THISCALL;
-	if (passed_regs < 1 && abi == FFI_THISCALL)
-	  abi = FFI_STDCALL;
-        ffi_call_win32(ffi_prep_args, &ecif, abi, cif->bytes, cif->flags,
-                       ecif.rvalue, fn);
-      }
-      break;
-#else
-    case FFI_SYSV:
-      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
-                    fn);
-      break;
-#endif
-    default:
-      FFI_ASSERT(0);
-      break;
-    }
-}
-
-
-/** private members **/
-
-/* The following __attribute__((regparm(1))) decorations will have no effect
-   on MSVC or SUNPRO_C -- standard conventions apply. */
-static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
-                                         void** args, ffi_cif* cif);
-void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
-     __attribute__ ((regparm(1)));
-unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
-     __attribute__ ((regparm(1)));
-void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
-     __attribute__ ((regparm(1)));
-#ifdef X86_WIN32
-void FFI_HIDDEN ffi_closure_raw_THISCALL (ffi_raw_closure *)
-     __attribute__ ((regparm(1)));
-void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
-     __attribute__ ((regparm(1)));
-void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *)
-     __attribute__ ((regparm(1)));
-#endif
-#ifdef X86_WIN64
-void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
-#endif
-
-/* This function is jumped to by the trampoline */
-
-#ifdef X86_WIN64
-void * FFI_HIDDEN
-ffi_closure_win64_inner (ffi_closure *closure, void *args) {
-  ffi_cif       *cif;
-  void         **arg_area;
-  void          *result;
-  void          *resp = &result;
-
-  cif         = closure->cif;
-  arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
-
-  /* this call will initialize ARG_AREA, such that each
-   * element in that array points to the corresponding 
-   * value on the stack; and if the function returns
-   * a structure, it will change RESP to point to the
-   * structure return address.  */
-
-  ffi_prep_incoming_args_SYSV(args, &resp, arg_area, cif);
-  
-  (closure->fun) (cif, resp, arg_area, closure->user_data);
-
-  /* The result is returned in rax.  This does the right thing for
-     result types except for floats; we have to 'mov xmm0, rax' in the
-     caller to correct this.
-     TODO: structure sizes of 3 5 6 7 are returned by reference, too!!!
-  */
-  return cif->rtype->size > sizeof(void *) ? resp : *(void **)resp;
-}
-
-#else
-unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
-ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
-{
-  /* our various things...  */
-  ffi_cif       *cif;
-  void         **arg_area;
-
-  cif         = closure->cif;
-  arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
-
-  /* this call will initialize ARG_AREA, such that each
-   * element in that array points to the corresponding 
-   * value on the stack; and if the function returns
-   * a structure, it will change RESP to point to the
-   * structure return address.  */
-
-  ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
-
-  (closure->fun) (cif, *respp, arg_area, closure->user_data);
-
-  return cif->flags;
-}
-#endif /* !X86_WIN64 */
-
-static void
-ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
-                            ffi_cif *cif)
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-
-#ifdef X86_WIN64
-  if (cif->rtype->size > sizeof(ffi_arg)
-      || (cif->flags == FFI_TYPE_STRUCT
-          && (cif->rtype->size != 1 && cif->rtype->size != 2
-              && cif->rtype->size != 4 && cif->rtype->size != 8))) {
-    *rvalue = *(void **) argp;
-    argp += sizeof(void *);
-  }
-#else
-  if ( cif->flags == FFI_TYPE_STRUCT
-       || cif->flags == FFI_TYPE_MS_STRUCT ) {
-    *rvalue = *(void **) argp;
-    argp += sizeof(void *);
-  }
-#endif
-
-  p_argv = avalue;
-
-  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(void*) - 1) & (size_t) argp) {
-        argp = (char *) ALIGN(argp, sizeof(void*));
-      }
-
-#ifdef X86_WIN64
-      if ((*p_arg)->size > sizeof(ffi_arg)
-          || ((*p_arg)->type == FFI_TYPE_STRUCT
-              && ((*p_arg)->size != 1 && (*p_arg)->size != 2
-                  && (*p_arg)->size != 4 && (*p_arg)->size != 8)))
-        {
-          z = sizeof(void *);
-          *p_argv = *(void **)argp;
-        }
-      else
-#endif
-        {
-          z = (*p_arg)->size;
-          
-          /* because we're little endian, this is what it turns into.   */
-          
-          *p_argv = (void*) argp;
-        }
-          
-      p_argv++;
-#ifdef X86_WIN64
-      argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
-#else
-      argp += z;
-#endif
-    }
-  
-  return;
-}
-
-#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
-{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
-   void*  __fun = (void*)(FUN); \
-   void*  __ctx = (void*)(CTX); \
-   *(unsigned char*) &__tramp[0] = 0x41; \
-   *(unsigned char*) &__tramp[1] = 0xbb; \
-   *(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
-   *(unsigned char*) &__tramp[6] = 0x48; \
-   *(unsigned char*) &__tramp[7] = 0xb8; \
-   *(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
-   *(unsigned char *)  &__tramp[16] = 0x49; \
-   *(unsigned char *)  &__tramp[17] = 0xba; \
-   *(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
-   *(unsigned char *)  &__tramp[26] = 0x41; \
-   *(unsigned char *)  &__tramp[27] = 0xff; \
-   *(unsigned char *)  &__tramp[28] = 0xe2; /* jmp %r10 */ \
- }
-
-/* How to make a trampoline.  Derived from gcc/config/i386/i386.c. */
-
-#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
-{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
-   unsigned int  __fun = (unsigned int)(FUN); \
-   unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + 10);  \
-   *(unsigned char*) &__tramp[0] = 0xb8; \
-   *(unsigned int*)  &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
-   *(unsigned char *)  &__tramp[5] = 0xe9; \
-   *(unsigned int*)  &__tramp[6] = __dis; /* jmp __fun  */ \
- }
-
-#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \
-{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
-   unsigned int  __fun = (unsigned int)(FUN); \
-   unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + 49);  \
-   unsigned short __size = (unsigned short)(SIZE); \
-   *(unsigned int *) &__tramp[0] = 0x8324048b;	/* mov (%esp), %eax */ \
-   *(unsigned int *) &__tramp[4] = 0x4c890cec;	/* sub $12, %esp */ \
-   *(unsigned int *) &__tramp[8] = 0x04890424;	/* mov %ecx, 4(%esp) */ \
-   *(unsigned char*) &__tramp[12] = 0x24;	/* mov %eax, (%esp) */ \
-   *(unsigned char*) &__tramp[13] = 0xb8; \
-   *(unsigned int *) &__tramp[14] = __size;	/* mov __size, %eax */ \
-   *(unsigned int *) &__tramp[18] = 0x08244c8d;	/* lea 8(%esp), %ecx */ \
-   *(unsigned int *) &__tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \
-   *(unsigned short*) &__tramp[26] = 0x0b74;	/* jz 1f */ \
-   *(unsigned int *) &__tramp[28] = 0x8908518b;	/* 2b: mov 8(%ecx), %edx */ \
-   *(unsigned int *) &__tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \
-   *(unsigned char*) &__tramp[36] = 0x48;	/* dec %eax */ \
-   *(unsigned short*) &__tramp[37] = 0xf575;	/* jnz 2b ; 1f: */ \
-   *(unsigned char*) &__tramp[39] = 0xb8; \
-   *(unsigned int*)  &__tramp[40] = __ctx; /* movl __ctx, %eax */ \
-   *(unsigned char *)  &__tramp[44] = 0xe8; \
-   *(unsigned int*)  &__tramp[45] = __dis; /* call __fun  */ \
-   *(unsigned char*)  &__tramp[49] = 0xc2; /* ret  */ \
-   *(unsigned short*)  &__tramp[50] = (__size + 8); /* ret (__size + 8)  */ \
- }
-
-#define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE)  \
-{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
-   unsigned int  __fun = (unsigned int)(FUN); \
-   unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + 10); \
-   unsigned short __size = (unsigned short)(SIZE); \
-   *(unsigned char*) &__tramp[0] = 0xb8; \
-   *(unsigned int*)  &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
-   *(unsigned char *)  &__tramp[5] = 0xe8; \
-   *(unsigned int*)  &__tramp[6] = __dis; /* call __fun  */ \
-   *(unsigned char *)  &__tramp[10] = 0xc2; \
-   *(unsigned short*)  &__tramp[11] = __size; /* ret __size  */ \
- }
-
-/* the cif must already be prep'ed */
-
-ffi_status
-ffi_prep_closure_loc (ffi_closure* closure,
-                      ffi_cif* cif,
-                      void (*fun)(ffi_cif*,void*,void**,void*),
-                      void *user_data,
-                      void *codeloc)
-{
-#ifdef X86_WIN64
-#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
-#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
-  if (cif->abi == FFI_WIN64) 
-    {
-      int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
-      FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
-                                 &ffi_closure_win64,
-                                 codeloc, mask);
-      /* make sure we can execute here */
-    }
-#else
-  if (cif->abi == FFI_SYSV)
-    {
-      FFI_INIT_TRAMPOLINE (&closure->tramp[0],
-                           &ffi_closure_SYSV,
-                           (void*)codeloc);
-    }
-#ifdef X86_WIN32
-  else if (cif->abi == FFI_THISCALL)
-    {
-      FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0],
-				    &ffi_closure_THISCALL,
-				    (void*)codeloc,
-				    cif->bytes);
-    }
-  else if (cif->abi == FFI_STDCALL)
-    {
-      FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0],
-                                   &ffi_closure_STDCALL,
-                                   (void*)codeloc, cif->bytes);
-    }
-  else if (cif->abi == FFI_MS_CDECL)
-    {
-      FFI_INIT_TRAMPOLINE (&closure->tramp[0],
-                           &ffi_closure_SYSV,
-                           (void*)codeloc);
-    }
-#endif /* X86_WIN32 */
-#endif /* !X86_WIN64 */
-  else
-    {
-      return FFI_BAD_ABI;
-    }
-    
-  closure->cif  = cif;
-  closure->user_data = user_data;
-  closure->fun  = fun;
-
-  return FFI_OK;
-}
-
-/* ------- Native raw API support -------------------------------- */
-
-#if !FFI_NO_RAW_API
-
-ffi_status
-ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
-                          ffi_cif* cif,
-                          void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
-                          void *user_data,
-                          void *codeloc)
-{
-  int i;
-
-  if (cif->abi != FFI_SYSV) {
-#ifdef X86_WIN32
-    if (cif->abi != FFI_THISCALL)
-#endif
-    return FFI_BAD_ABI;
-  }
-
-  /* we currently don't support certain kinds of arguments for raw
-     closures.  This should be implemented by a separate assembly
-     language routine, since it would require argument processing,
-     something we don't do now for performance.  */
-
-  for (i = cif->nargs-1; i >= 0; i--)
-    {
-      FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
-      FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
-    }
-  
-#ifdef X86_WIN32
-  if (cif->abi == FFI_SYSV)
-    {
-#endif
-  FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
-                       codeloc);
-#ifdef X86_WIN32
-    }
-  else if (cif->abi == FFI_THISCALL)
-    {
-      FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL,
-				    codeloc, cif->bytes);
-    }
-#endif
-  closure->cif  = cif;
-  closure->user_data = user_data;
-  closure->fun  = fun;
-
-  return FFI_OK;
-}
-
-static void 
-ffi_prep_args_raw(char *stack, extended_cif *ecif)
-{
-  memcpy (stack, ecif->avalue, ecif->cif->bytes);
-}
-
-/* we borrow this routine from libffi (it must be changed, though, to
- * actually call the function passed in the first argument.  as of
- * libffi-1.20, this is not the case.)
- */
-
-void
-ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
-{
-  extended_cif ecif;
-  void **avalue = (void **)fake_avalue;
-
-  ecif.cif = cif;
-  ecif.avalue = avalue;
-  
-  /* If the return value is a struct and we don't have a return */
-  /* value address then we need to make one                     */
-
-  if (rvalue == NULL
-      && (cif->flags == FFI_TYPE_STRUCT
-          || cif->flags == FFI_TYPE_MS_STRUCT))
-    {
-      ecif.rvalue = alloca(cif->rtype->size);
-    }
-  else
-    ecif.rvalue = rvalue;
-    
-  
-  switch (cif->abi) 
-    {
-#ifdef X86_WIN32
-    case FFI_SYSV:
-    case FFI_STDCALL:
-    case FFI_MS_CDECL:
-      ffi_call_win32(ffi_prep_args_raw, &ecif, cif->abi, cif->bytes, cif->flags,
-		     ecif.rvalue, fn);
-      break;
-    case FFI_THISCALL:
-    case FFI_FASTCALL:
-      {
-	unsigned int abi = cif->abi;
-	unsigned int i, passed_regs = 0;
-
-	if (cif->flags == FFI_TYPE_STRUCT)
-	  ++passed_regs;
-
-	for (i=0; i < cif->nargs && passed_regs < 2;i++)
-	  {
-	    size_t sz;
-
-	    if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
-	        || cif->arg_types[i]->type == FFI_TYPE_STRUCT)
-	      continue;
-	    sz = (cif->arg_types[i]->size + 3) & ~3;
-	    if (sz == 0 || sz > 4)
-	      continue;
-	    ++passed_regs;
-	  }
-	if (passed_regs < 2 && abi == FFI_FASTCALL)
-	  cif->abi = abi = FFI_THISCALL;
-	if (passed_regs < 1 && abi == FFI_THISCALL)
-	  cif->abi = abi = FFI_STDCALL;
-        ffi_call_win32(ffi_prep_args_raw, &ecif, abi, cif->bytes, cif->flags,
-                       ecif.rvalue, fn);
-      }
-      break;
-#else
-    case FFI_SYSV:
-      ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
-                    ecif.rvalue, fn);
-      break;
-#endif
-    default:
-      FFI_ASSERT(0);
-      break;
-    }
-}
-
-#endif
-
-#endif /* !__x86_64__  || X86_WIN64 */
-
diff --git a/lib/wrappers/libffi/gcc/ffi64.c b/lib/wrappers/libffi/gcc/ffi64.c
deleted file mode 100644
index 2014af24c..000000000
--- a/lib/wrappers/libffi/gcc/ffi64.c
+++ /dev/null
@@ -1,673 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi64.c - Copyright (c) 2013  The Written Word, Inc.
-             Copyright (c) 2011  Anthony Green
-             Copyright (c) 2008, 2010  Red Hat, Inc.
-             Copyright (c) 2002, 2007  Bo Thorsen <bo@suse.de>
-             
-   x86-64 Foreign Function Interface 
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-#include <stdarg.h>
-
-#ifdef __x86_64__
-
-#define MAX_GPR_REGS 6
-#define MAX_SSE_REGS 8
-
-#if defined(__INTEL_COMPILER)
-#define UINT128 __m128
-#else
-#if defined(__SUNPRO_C)
-#include <sunmedia_types.h>
-#define UINT128 __m128i
-#else
-#define UINT128 __int128_t
-#endif
-#endif
-
-union big_int_union
-{
-  UINT32 i32;
-  UINT64 i64;
-  UINT128 i128;
-};
-
-struct register_args
-{
-  /* Registers for argument passing.  */
-  UINT64 gpr[MAX_GPR_REGS];
-  union big_int_union sse[MAX_SSE_REGS]; 
-};
-
-extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
-			     void *raddr, void (*fnaddr)(void), unsigned ssecount);
-
-/* All reference to register classes here is identical to the code in
-   gcc/config/i386/i386.c. Do *not* change one without the other.  */
-
-/* Register class used for passing given 64bit part of the argument.
-   These represent classes as documented by the PS ABI, with the
-   exception of SSESF, SSEDF classes, that are basically SSE class,
-   just gcc will use SF or DFmode move instead of DImode to avoid
-   reformatting penalties.
-
-   Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
-   whenever possible (upper half does contain padding).  */
-enum x86_64_reg_class
-  {
-    X86_64_NO_CLASS,
-    X86_64_INTEGER_CLASS,
-    X86_64_INTEGERSI_CLASS,
-    X86_64_SSE_CLASS,
-    X86_64_SSESF_CLASS,
-    X86_64_SSEDF_CLASS,
-    X86_64_SSEUP_CLASS,
-    X86_64_X87_CLASS,
-    X86_64_X87UP_CLASS,
-    X86_64_COMPLEX_X87_CLASS,
-    X86_64_MEMORY_CLASS
-  };
-
-#define MAX_CLASSES 4
-
-#define SSE_CLASS_P(X)	((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS)
-
-/* x86-64 register passing implementation.  See x86-64 ABI for details.  Goal
-   of this code is to classify each 8bytes of incoming argument by the register
-   class and assign registers accordingly.  */
-
-/* Return the union class of CLASS1 and CLASS2.
-   See the x86-64 PS ABI for details.  */
-
-static enum x86_64_reg_class
-merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
-{
-  /* Rule #1: If both classes are equal, this is the resulting class.  */
-  if (class1 == class2)
-    return class1;
-
-  /* Rule #2: If one of the classes is NO_CLASS, the resulting class is
-     the other class.  */
-  if (class1 == X86_64_NO_CLASS)
-    return class2;
-  if (class2 == X86_64_NO_CLASS)
-    return class1;
-
-  /* Rule #3: If one of the classes is MEMORY, the result is MEMORY.  */
-  if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
-    return X86_64_MEMORY_CLASS;
-
-  /* Rule #4: If one of the classes is INTEGER, the result is INTEGER.  */
-  if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
-      || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
-    return X86_64_INTEGERSI_CLASS;
-  if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
-      || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
-    return X86_64_INTEGER_CLASS;
-
-  /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
-     MEMORY is used.  */
-  if (class1 == X86_64_X87_CLASS
-      || class1 == X86_64_X87UP_CLASS
-      || class1 == X86_64_COMPLEX_X87_CLASS
-      || class2 == X86_64_X87_CLASS
-      || class2 == X86_64_X87UP_CLASS
-      || class2 == X86_64_COMPLEX_X87_CLASS)
-    return X86_64_MEMORY_CLASS;
-
-  /* Rule #6: Otherwise class SSE is used.  */
-  return X86_64_SSE_CLASS;
-}
-
-/* Classify the argument of type TYPE and mode MODE.
-   CLASSES will be filled by the register class used to pass each word
-   of the operand.  The number of words is returned.  In case the parameter
-   should be passed in memory, 0 is returned. As a special case for zero
-   sized containers, classes[0] will be NO_CLASS and 1 is returned.
-
-   See the x86-64 PS ABI for details.
-*/
-static int
-classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
-		   size_t byte_offset)
-{
-  switch (type->type)
-    {
-    case FFI_TYPE_UINT8:
-    case FFI_TYPE_SINT8:
-    case FFI_TYPE_UINT16:
-    case FFI_TYPE_SINT16:
-    case FFI_TYPE_UINT32:
-    case FFI_TYPE_SINT32:
-    case FFI_TYPE_UINT64:
-    case FFI_TYPE_SINT64:
-    case FFI_TYPE_POINTER:
-      {
-	int size = byte_offset + type->size;
-
-	if (size <= 4)
-	  {
-	    classes[0] = X86_64_INTEGERSI_CLASS;
-	    return 1;
-	  }
-	else if (size <= 8)
-	  {
-	    classes[0] = X86_64_INTEGER_CLASS;
-	    return 1;
-	  }
-	else if (size <= 12)
-	  {
-	    classes[0] = X86_64_INTEGER_CLASS;
-	    classes[1] = X86_64_INTEGERSI_CLASS;
-	    return 2;
-	  }
-	else if (size <= 16)
-	  {
-	    classes[0] = classes[1] = X86_64_INTEGERSI_CLASS;
-	    return 2;
-	  }
-	else
-	  FFI_ASSERT (0);
-      }
-    case FFI_TYPE_FLOAT:
-      if (!(byte_offset % 8))
-	classes[0] = X86_64_SSESF_CLASS;
-      else
-	classes[0] = X86_64_SSE_CLASS;
-      return 1;
-    case FFI_TYPE_DOUBLE:
-      classes[0] = X86_64_SSEDF_CLASS;
-      return 1;
-    case FFI_TYPE_LONGDOUBLE:
-      classes[0] = X86_64_X87_CLASS;
-      classes[1] = X86_64_X87UP_CLASS;
-      return 2;
-    case FFI_TYPE_STRUCT:
-      {
-	const int UNITS_PER_WORD = 8;
-	int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
-	ffi_type **ptr; 
-	int i;
-	enum x86_64_reg_class subclasses[MAX_CLASSES];
-
-	/* If the struct is larger than 32 bytes, pass it on the stack.  */
-	if (type->size > 32)
-	  return 0;
-
-	for (i = 0; i < words; i++)
-	  classes[i] = X86_64_NO_CLASS;
-
-	/* Zero sized arrays or structures are NO_CLASS.  We return 0 to
-	   signalize memory class, so handle it as special case.  */
-	if (!words)
-	  {
-	    classes[0] = X86_64_NO_CLASS;
-	    return 1;
-	  }
-
-	/* Merge the fields of structure.  */
-	for (ptr = type->elements; *ptr != NULL; ptr++)
-	  {
-	    int num;
-
-	    byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
-
-	    num = classify_argument (*ptr, subclasses, byte_offset % 8);
-	    if (num == 0)
-	      return 0;
-	    for (i = 0; i < num; i++)
-	      {
-		int pos = byte_offset / 8;
-		classes[i + pos] =
-		  merge_classes (subclasses[i], classes[i + pos]);
-	      }
-
-	    byte_offset += (*ptr)->size;
-	  }
-
-	if (words > 2)
-	  {
-	    /* When size > 16 bytes, if the first one isn't
-	       X86_64_SSE_CLASS or any other ones aren't
-	       X86_64_SSEUP_CLASS, everything should be passed in
-	       memory.  */
-	    if (classes[0] != X86_64_SSE_CLASS)
-	      return 0;
-
-	    for (i = 1; i < words; i++)
-	      if (classes[i] != X86_64_SSEUP_CLASS)
-		return 0;
-	  }
-
-	/* Final merger cleanup.  */
-	for (i = 0; i < words; i++)
-	  {
-	    /* If one class is MEMORY, everything should be passed in
-	       memory.  */
-	    if (classes[i] == X86_64_MEMORY_CLASS)
-	      return 0;
-
-	    /* The X86_64_SSEUP_CLASS should be always preceded by
-	       X86_64_SSE_CLASS or X86_64_SSEUP_CLASS.  */
-	    if (classes[i] == X86_64_SSEUP_CLASS
-		&& classes[i - 1] != X86_64_SSE_CLASS
-		&& classes[i - 1] != X86_64_SSEUP_CLASS)
-	      {
-		/* The first one should never be X86_64_SSEUP_CLASS.  */
-		FFI_ASSERT (i != 0);
-		classes[i] = X86_64_SSE_CLASS;
-	      }
-
-	    /*  If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
-		everything should be passed in memory.  */
-	    if (classes[i] == X86_64_X87UP_CLASS
-		&& (classes[i - 1] != X86_64_X87_CLASS))
-	      {
-		/* The first one should never be X86_64_X87UP_CLASS.  */
-		FFI_ASSERT (i != 0);
-		return 0;
-	      }
-	  }
-	return words;
-      }
-
-    default:
-      FFI_ASSERT(0);
-    }
-  return 0; /* Never reached.  */
-}
-
-/* Examine the argument and return set number of register required in each
-   class.  Return zero iff parameter should be passed in memory, otherwise
-   the number of registers.  */
-
-static int
-examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
-		  _Bool in_return, int *pngpr, int *pnsse)
-{
-  int i, n, ngpr, nsse;
-
-  n = classify_argument (type, classes, 0);
-  if (n == 0)
-    return 0;
-
-  ngpr = nsse = 0;
-  for (i = 0; i < n; ++i)
-    switch (classes[i])
-      {
-      case X86_64_INTEGER_CLASS:
-      case X86_64_INTEGERSI_CLASS:
-	ngpr++;
-	break;
-      case X86_64_SSE_CLASS:
-      case X86_64_SSESF_CLASS:
-      case X86_64_SSEDF_CLASS:
-	nsse++;
-	break;
-      case X86_64_NO_CLASS:
-      case X86_64_SSEUP_CLASS:
-	break;
-      case X86_64_X87_CLASS:
-      case X86_64_X87UP_CLASS:
-      case X86_64_COMPLEX_X87_CLASS:
-	return in_return != 0;
-      default:
-	abort ();
-      }
-
-  *pngpr = ngpr;
-  *pnsse = nsse;
-
-  return n;
-}
-
-/* Perform machine dependent cif processing.  */
-
-ffi_status
-ffi_prep_cif_machdep (ffi_cif *cif)
-{
-  int gprcount, ssecount, i, avn, n, ngpr, nsse, flags;
-  enum x86_64_reg_class classes[MAX_CLASSES];
-  size_t bytes;
-
-  gprcount = ssecount = 0;
-
-  flags = cif->rtype->type;
-  if (flags != FFI_TYPE_VOID)
-    {
-      n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
-      if (n == 0)
-	{
-	  /* The return value is passed in memory.  A pointer to that
-	     memory is the first argument.  Allocate a register for it.  */
-	  gprcount++;
-	  /* We don't have to do anything in asm for the return.  */
-	  flags = FFI_TYPE_VOID;
-	}
-      else if (flags == FFI_TYPE_STRUCT)
-	{
-	  /* Mark which registers the result appears in.  */
-	  _Bool sse0 = SSE_CLASS_P (classes[0]);
-	  _Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]);
-	  if (sse0 && !sse1)
-	    flags |= 1 << 8;
-	  else if (!sse0 && sse1)
-	    flags |= 1 << 9;
-	  else if (sse0 && sse1)
-	    flags |= 1 << 10;
-	  /* Mark the true size of the structure.  */
-	  flags |= cif->rtype->size << 12;
-	}
-    }
-
-  /* Go over all arguments and determine the way they should be passed.
-     If it's in a register and there is space for it, let that be so. If
-     not, add it's size to the stack byte count.  */
-  for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++)
-    {
-      if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0
-	  || gprcount + ngpr > MAX_GPR_REGS
-	  || ssecount + nsse > MAX_SSE_REGS)
-	{
-	  long align = cif->arg_types[i]->alignment;
-
-	  if (align < 8)
-	    align = 8;
-
-	  bytes = ALIGN (bytes, align);
-	  bytes += cif->arg_types[i]->size;
-	}
-      else
-	{
-	  gprcount += ngpr;
-	  ssecount += nsse;
-	}
-    }
-  if (ssecount)
-    flags |= 1 << 11;
-  cif->flags = flags;
-  cif->bytes = ALIGN (bytes, 8);
-
-  return FFI_OK;
-}
-
-void
-ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
-{
-  enum x86_64_reg_class classes[MAX_CLASSES];
-  char *stack, *argp;
-  ffi_type **arg_types;
-  int gprcount, ssecount, ngpr, nsse, i, avn;
-  _Bool ret_in_memory;
-  struct register_args *reg_args;
-
-  /* Can't call 32-bit mode from 64-bit mode.  */
-  FFI_ASSERT (cif->abi == FFI_UNIX64);
-
-  /* If the return value is a struct and we don't have a return value
-     address then we need to make one.  Note the setting of flags to
-     VOID above in ffi_prep_cif_machdep.  */
-  ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT
-		   && (cif->flags & 0xff) == FFI_TYPE_VOID);
-  if (rvalue == NULL && ret_in_memory)
-    rvalue = alloca (cif->rtype->size);
-
-  /* Allocate the space for the arguments, plus 4 words of temp space.  */
-  stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8);
-  reg_args = (struct register_args *) stack;
-  argp = stack + sizeof (struct register_args);
-
-  gprcount = ssecount = 0;
-
-  /* If the return value is passed in memory, add the pointer as the
-     first integer argument.  */
-  if (ret_in_memory)
-    reg_args->gpr[gprcount++] = (unsigned long) rvalue;
-
-  avn = cif->nargs;
-  arg_types = cif->arg_types;
-
-  for (i = 0; i < avn; ++i)
-    {
-      size_t size = arg_types[i]->size;
-      int n;
-
-      n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
-      if (n == 0
-	  || gprcount + ngpr > MAX_GPR_REGS
-	  || ssecount + nsse > MAX_SSE_REGS)
-	{
-	  long align = arg_types[i]->alignment;
-
-	  /* Stack arguments are *always* at least 8 byte aligned.  */
-	  if (align < 8)
-	    align = 8;
-
-	  /* Pass this argument in memory.  */
-	  argp = (void *) ALIGN (argp, align);
-	  memcpy (argp, avalue[i], size);
-	  argp += size;
-	}
-      else
-	{
-	  /* The argument is passed entirely in registers.  */
-	  char *a = (char *) avalue[i];
-	  int j;
-
-	  for (j = 0; j < n; j++, a += 8, size -= 8)
-	    {
-	      switch (classes[j])
-		{
-		case X86_64_INTEGER_CLASS:
-		case X86_64_INTEGERSI_CLASS:
-		  /* Sign-extend integer arguments passed in general
-		     purpose registers, to cope with the fact that
-		     LLVM incorrectly assumes that this will be done
-		     (the x86-64 PS ABI does not specify this). */
-		  switch (arg_types[i]->type)
-		    {
-		    case FFI_TYPE_SINT8:
-		      *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
-		      break;
-		    case FFI_TYPE_SINT16:
-		      *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
-		      break;
-		    case FFI_TYPE_SINT32:
-		      *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
-		      break;
-		    default:
-		      reg_args->gpr[gprcount] = 0;
-		      memcpy (&reg_args->gpr[gprcount], a, size < 8 ? size : 8);
-		    }
-		  gprcount++;
-		  break;
-		case X86_64_SSE_CLASS:
-		case X86_64_SSEDF_CLASS:
-		  reg_args->sse[ssecount++].i64 = *(UINT64 *) a;
-		  break;
-		case X86_64_SSESF_CLASS:
-		  reg_args->sse[ssecount++].i32 = *(UINT32 *) a;
-		  break;
-		default:
-		  abort();
-		}
-	    }
-	}
-    }
-
-  ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
-		   cif->flags, rvalue, fn, ssecount);
-}
-
-
-extern void ffi_closure_unix64(void);
-
-ffi_status
-ffi_prep_closure_loc (ffi_closure* closure,
-		      ffi_cif* cif,
-		      void (*fun)(ffi_cif*, void*, void**, void*),
-		      void *user_data,
-		      void *codeloc)
-{
-  volatile unsigned short *tramp;
-
-  /* Sanity check on the cif ABI.  */
-  {
-    int abi = cif->abi;
-    if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
-      return FFI_BAD_ABI;
-  }
-
-  tramp = (volatile unsigned short *) &closure->tramp[0];
-
-  tramp[0] = 0xbb49;		/* mov <code>, %r11	*/
-  *((unsigned long long * volatile) &tramp[1])
-    = (unsigned long) ffi_closure_unix64;
-  tramp[5] = 0xba49;		/* mov <data>, %r10	*/
-  *((unsigned long long * volatile) &tramp[6])
-    = (unsigned long) codeloc;
-
-  /* Set the carry bit iff the function uses any sse registers.
-     This is clc or stc, together with the first byte of the jmp.  */
-  tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8;
-
-  tramp[11] = 0xe3ff;			/* jmp *%r11    */
-
-  closure->cif = cif;
-  closure->fun = fun;
-  closure->user_data = user_data;
-
-  return FFI_OK;
-}
-
-int
-ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
-			 struct register_args *reg_args, char *argp)
-{
-  ffi_cif *cif;
-  void **avalue;
-  ffi_type **arg_types;
-  long i, avn;
-  int gprcount, ssecount, ngpr, nsse;
-  int ret;
-
-  cif = closure->cif;
-  avalue = alloca(cif->nargs * sizeof(void *));
-  gprcount = ssecount = 0;
-
-  ret = cif->rtype->type;
-  if (ret != FFI_TYPE_VOID)
-    {
-      enum x86_64_reg_class classes[MAX_CLASSES];
-      int n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
-      if (n == 0)
-	{
-	  /* The return value goes in memory.  Arrange for the closure
-	     return value to go directly back to the original caller.  */
-	  rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++];
-	  /* We don't have to do anything in asm for the return.  */
-	  ret = FFI_TYPE_VOID;
-	}
-      else if (ret == FFI_TYPE_STRUCT && n == 2)
-	{
-	  /* Mark which register the second word of the structure goes in.  */
-	  _Bool sse0 = SSE_CLASS_P (classes[0]);
-	  _Bool sse1 = SSE_CLASS_P (classes[1]);
-	  if (!sse0 && sse1)
-	    ret |= 1 << 8;
-	  else if (sse0 && !sse1)
-	    ret |= 1 << 9;
-	}
-    }
-
-  avn = cif->nargs;
-  arg_types = cif->arg_types;
-  
-  for (i = 0; i < avn; ++i)
-    {
-      enum x86_64_reg_class classes[MAX_CLASSES];
-      int n;
-
-      n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
-      if (n == 0
-	  || gprcount + ngpr > MAX_GPR_REGS
-	  || ssecount + nsse > MAX_SSE_REGS)
-	{
-	  long align = arg_types[i]->alignment;
-
-	  /* Stack arguments are *always* at least 8 byte aligned.  */
-	  if (align < 8)
-	    align = 8;
-
-	  /* Pass this argument in memory.  */
-	  argp = (void *) ALIGN (argp, align);
-	  avalue[i] = argp;
-	  argp += arg_types[i]->size;
-	}
-      /* If the argument is in a single register, or two consecutive
-	 integer registers, then we can use that address directly.  */
-      else if (n == 1
-	       || (n == 2 && !(SSE_CLASS_P (classes[0])
-			       || SSE_CLASS_P (classes[1]))))
-	{
-	  /* The argument is in a single register.  */
-	  if (SSE_CLASS_P (classes[0]))
-	    {
-	      avalue[i] = &reg_args->sse[ssecount];
-	      ssecount += n;
-	    }
-	  else
-	    {
-	      avalue[i] = &reg_args->gpr[gprcount];
-	      gprcount += n;
-	    }
-	}
-      /* Otherwise, allocate space to make them consecutive.  */
-      else
-	{
-	  char *a = alloca (16);
-	  int j;
-
-	  avalue[i] = a;
-	  for (j = 0; j < n; j++, a += 8)
-	    {
-	      if (SSE_CLASS_P (classes[j]))
-		memcpy (a, &reg_args->sse[ssecount++], 8);
-	      else
-		memcpy (a, &reg_args->gpr[gprcount++], 8);
-	    }
-	}
-    }
-
-  /* Invoke the closure.  */
-  closure->fun (cif, rvalue, avalue, closure->user_data);
-
-  /* Tell assembly how to perform return type promotions.  */
-  return ret;
-}
-
-#endif /* __x86_64__ */
diff --git a/lib/wrappers/libffi/gcc/prep_cif.c b/lib/wrappers/libffi/gcc/prep_cif.c
deleted file mode 100644
index e8ec5cf1e..000000000
--- a/lib/wrappers/libffi/gcc/prep_cif.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -----------------------------------------------------------------------
-   prep_cif.c - Copyright (c) 2011, 2012  Anthony Green
-                Copyright (c) 1996, 1998, 2007  Red Hat, Inc.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-#include <stdlib.h>
-
-/* Round up to FFI_SIZEOF_ARG. */
-
-#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
-
-/* Perform machine independent initialization of aggregate type
-   specifications. */
-
-static ffi_status initialize_aggregate(ffi_type *arg)
-{
-  ffi_type **ptr;
-
-  if (UNLIKELY(arg == NULL || arg->elements == NULL))
-    return FFI_BAD_TYPEDEF;
-
-  arg->size = 0;
-  arg->alignment = 0;
-
-  ptr = &(arg->elements[0]);
-
-  if (UNLIKELY(ptr == 0))
-    return FFI_BAD_TYPEDEF;
-
-  while ((*ptr) != NULL)
-    {
-      if (UNLIKELY(((*ptr)->size == 0)
-		    && (initialize_aggregate((*ptr)) != FFI_OK)))
-	return FFI_BAD_TYPEDEF;
-
-      /* Perform a sanity check on the argument type */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-      arg->size = ALIGN(arg->size, (*ptr)->alignment);
-      arg->size += (*ptr)->size;
-
-      arg->alignment = (arg->alignment > (*ptr)->alignment) ?
-	arg->alignment : (*ptr)->alignment;
-
-      ptr++;
-    }
-
-  /* Structure size includes tail padding.  This is important for
-     structures that fit in one register on ABIs like the PowerPC64
-     Linux ABI that right justify small structs in a register.
-     It's also needed for nested structure layout, for example
-     struct A { long a; char b; }; struct B { struct A x; char y; };
-     should find y at an offset of 2*sizeof(long) and result in a
-     total size of 3*sizeof(long).  */
-  arg->size = ALIGN (arg->size, arg->alignment);
-
-  if (arg->size == 0)
-    return FFI_BAD_TYPEDEF;
-  else
-    return FFI_OK;
-}
-
-#ifndef __CRIS__
-/* The CRIS ABI specifies structure elements to have byte
-   alignment only, so it completely overrides this functions,
-   which assumes "natural" alignment and padding.  */
-
-/* Perform machine independent ffi_cif preparation, then call
-   machine dependent routine. */
-
-/* For non variadic functions isvariadic should be 0 and
-   nfixedargs==ntotalargs.
-
-   For variadic calls, isvariadic should be 1 and nfixedargs
-   and ntotalargs set as appropriate. nfixedargs must always be >=1 */
-
-
-ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
-			     unsigned int isvariadic,
-                             unsigned int nfixedargs,
-                             unsigned int ntotalargs,
-			     ffi_type *rtype, ffi_type **atypes)
-{
-  unsigned bytes = 0;
-  unsigned int i;
-  ffi_type **ptr;
-
-  FFI_ASSERT(cif != NULL);
-  FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
-  FFI_ASSERT(nfixedargs <= ntotalargs);
-
-#ifndef X86_WIN32
-  if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))
-    return FFI_BAD_ABI;
-#else
-  if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI || abi == FFI_THISCALL))
-    return FFI_BAD_ABI;
-#endif
-
-  cif->abi = abi;
-  cif->arg_types = atypes;
-  cif->nargs = ntotalargs;
-  cif->rtype = rtype;
-
-  cif->flags = 0;
-
-  /* Initialize the return type if necessary */
-  if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
-    return FFI_BAD_TYPEDEF;
-
-  /* Perform a sanity check on the return type */
-  FFI_ASSERT_VALID_TYPE(cif->rtype);
-
-  /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */
-#if !defined M68K && !defined X86_ANY && !defined S390 && !defined PA
-  /* Make space for the return structure pointer */
-  if (cif->rtype->type == FFI_TYPE_STRUCT
-#ifdef SPARC
-      && (cif->abi != FFI_V9 || cif->rtype->size > 32)
-#endif
-#ifdef TILE
-      && (cif->rtype->size > 10 * FFI_SIZEOF_ARG)
-#endif
-#ifdef XTENSA
-      && (cif->rtype->size > 16)
-#endif
-
-     )
-    bytes = STACK_ARG_SIZE(sizeof(void*));
-#endif
-
-  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
-    {
-
-      /* Initialize any uninitialized aggregate type definitions */
-      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
-	return FFI_BAD_TYPEDEF;
-
-      /* Perform a sanity check on the argument type, do this
-	 check after the initialization.  */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-#if !defined X86_ANY && !defined S390 && !defined PA
-#ifdef SPARC
-      if (((*ptr)->type == FFI_TYPE_STRUCT
-	   && ((*ptr)->size > 16 || cif->abi != FFI_V9))
-	  || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
-	      && cif->abi != FFI_V9))
-	bytes += sizeof(void*);
-      else
-#endif
-	{
-	  /* Add any padding if necessary */
-	  if (((*ptr)->alignment - 1) & bytes)
-	    bytes = ALIGN(bytes, (*ptr)->alignment);
-
-#ifdef TILE
-	  if (bytes < 10 * FFI_SIZEOF_ARG &&
-	      bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG)
-	    {
-	      /* An argument is never split between the 10 parameter
-		 registers and the stack.  */
-	      bytes = 10 * FFI_SIZEOF_ARG;
-	    }
-#endif
-#ifdef XTENSA
-	  if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4)
-	    bytes = 6*4;
-#endif
-
-	  bytes += STACK_ARG_SIZE((*ptr)->size);
-	}
-#endif
-    }
-
-  cif->bytes = bytes;
-
-  /* Perform machine dependent cif processing */
-#ifdef FFI_TARGET_SPECIFIC_VARIADIC
-  if (isvariadic)
-	return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs);
-#endif
-
-  return ffi_prep_cif_machdep(cif);
-}
-#endif /* not __CRIS__ */
-
-ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs,
-			     ffi_type *rtype, ffi_type **atypes)
-{
-  return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes);
-}
-
-ffi_status ffi_prep_cif_var(ffi_cif *cif,
-                            ffi_abi abi,
-                            unsigned int nfixedargs,
-                            unsigned int ntotalargs,
-                            ffi_type *rtype,
-                            ffi_type **atypes)
-{
-  return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes);
-}
-
-#if FFI_CLOSURES
-
-ffi_status
-ffi_prep_closure (ffi_closure* closure,
-		  ffi_cif* cif,
-		  void (*fun)(ffi_cif*,void*,void**,void*),
-		  void *user_data)
-{
-  return ffi_prep_closure_loc (closure, cif, fun, user_data, closure);
-}
-
-#endif
diff --git a/lib/wrappers/libffi/gcc/types.c b/lib/wrappers/libffi/gcc/types.c
deleted file mode 100644
index 0a11eb0fb..000000000
--- a/lib/wrappers/libffi/gcc/types.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -----------------------------------------------------------------------
-   types.c - Copyright (c) 1996, 1998  Red Hat, Inc.
-   
-   Predefined ffi_types needed by libffi.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-/* Hide the basic type definitions from the header file, so that we
-   can redefine them here as "const".  */
-#define LIBFFI_HIDE_BASIC_TYPES
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-/* Type definitions */
-
-#define FFI_TYPEDEF(name, type, id)		\
-struct struct_align_##name {			\
-  char c;					\
-  type x;					\
-};						\
-const ffi_type ffi_type_##name = {		\
-  sizeof(type),					\
-  offsetof(struct struct_align_##name, x),	\
-  id, NULL					\
-}
-
-/* Size and alignment are fake here. They must not be 0. */
-const ffi_type ffi_type_void = {
-  1, 1, FFI_TYPE_VOID, NULL
-};
-
-FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8);
-FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8);
-FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16);
-FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16);
-FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32);
-FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32);
-FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64);
-FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64);
-
-FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER);
-
-FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT);
-FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
-
-#ifdef __alpha__
-/* Even if we're not configured to default to 128-bit long double, 
-   maintain binary compatibility, as -mlong-double-128 can be used
-   at any time.  */
-/* Validate the hard-coded number below.  */
-# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4
-#  error FFI_TYPE_LONGDOUBLE out of date
-# endif
-const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
-#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
-#endif
diff --git a/lib/wrappers/libffi/gcc/win32_asm.asm b/lib/wrappers/libffi/gcc/win32_asm.asm
deleted file mode 100644
index ce3c4f3f3..000000000
--- a/lib/wrappers/libffi/gcc/win32_asm.asm
+++ /dev/null
@@ -1,759 +0,0 @@
-/* -----------------------------------------------------------------------
-   win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009  Red Hat, Inc.
-	     Copyright (c) 2001  John Beniton
-	     Copyright (c) 2002  Ranjit Mathew
-	     Copyright (c) 2009  Daniel Witte
-			
- 
-   X86 Foreign Function Interface
- 
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
- 
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
- 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   -----------------------------------------------------------------------
-   */
- 
-#define LIBFFI_ASM
-#include <fficonfig.h>
-#include <ffi.h>
-#include <ffitarget.h>
-
-	.text
- 
-        // This assumes we are using gas.
-        .balign 16
-	.globl	_ffi_call_win32
-#ifndef __OS2__
-	.def	_ffi_call_win32;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_call_win32:
-.LFB1:
-        pushl %ebp
-.LCFI0:
-        movl  %esp,%ebp
-.LCFI1:
-        // Make room for all of the new args.
-        movl  20(%ebp),%ecx                                                     
-        subl  %ecx,%esp
- 
-        movl  %esp,%eax
- 
-        // Place all of the ffi_prep_args in position
-        pushl 12(%ebp)
-        pushl %eax
-        call  *8(%ebp)
- 
-        // Return stack to previous state and call the function
-        addl  $8,%esp
-
-	// Handle fastcall and thiscall
-	cmpl $3, 16(%ebp)  // FFI_THISCALL
-	jz .do_thiscall
-	cmpl $4, 16(%ebp) // FFI_FASTCALL
-	jnz .do_fncall
-	movl (%esp), %ecx
-	movl 4(%esp), %edx
-	addl $8, %esp
-	jmp .do_fncall
-.do_thiscall:
-	movl (%esp), %ecx
-	addl $4, %esp
-
-.do_fncall:
-	 
-        // FIXME: Align the stack to a 128-bit boundary to avoid
-        // potential performance hits.
-
-        call  *32(%ebp)
- 
-        // stdcall functions pop arguments off the stack themselves
-
-        // Load %ecx with the return type code
-        movl  24(%ebp),%ecx
- 
-        // If the return value pointer is NULL, assume no return value.
-        cmpl  $0,28(%ebp)
-        jne   0f
- 
-        // Even if there is no space for the return value, we are
-        // obliged to handle floating-point values.
-        cmpl  $FFI_TYPE_FLOAT,%ecx
-        jne   .Lnoretval
-        fstp  %st(0)
- 
-        jmp   .Lepilogue
-
-0:
-	call	1f
-	// Do not insert anything here between the call and the jump table.
-.Lstore_table:
-	.long	.Lnoretval		/* FFI_TYPE_VOID */
-	.long	.Lretint		/* FFI_TYPE_INT */
-	.long	.Lretfloat		/* FFI_TYPE_FLOAT */
-	.long	.Lretdouble		/* FFI_TYPE_DOUBLE */
-	.long	.Lretlongdouble		/* FFI_TYPE_LONGDOUBLE */
-	.long	.Lretuint8		/* FFI_TYPE_UINT8 */
-	.long	.Lretsint8		/* FFI_TYPE_SINT8 */
-	.long	.Lretuint16		/* FFI_TYPE_UINT16 */
-	.long	.Lretsint16		/* FFI_TYPE_SINT16 */
-	.long	.Lretint		/* FFI_TYPE_UINT32 */
-	.long	.Lretint		/* FFI_TYPE_SINT32 */
-	.long	.Lretint64		/* FFI_TYPE_UINT64 */
-	.long	.Lretint64		/* FFI_TYPE_SINT64 */
-	.long	.Lretstruct		/* FFI_TYPE_STRUCT */
-	.long	.Lretint		/* FFI_TYPE_POINTER */
-	.long	.Lretstruct1b		/* FFI_TYPE_SMALL_STRUCT_1B */
-	.long	.Lretstruct2b		/* FFI_TYPE_SMALL_STRUCT_2B */
-	.long	.Lretstruct4b		/* FFI_TYPE_SMALL_STRUCT_4B */
-	.long	.Lretstruct		/* FFI_TYPE_MS_STRUCT */
-1:
-	add	%ecx, %ecx
-	add	%ecx, %ecx
-	add	(%esp),%ecx
-	add	$4, %esp
-	jmp	*(%ecx)
-
-	/* Sign/zero extend as appropriate.  */
-.Lretsint8:
-	movsbl	%al, %eax
-	jmp	.Lretint
-
-.Lretsint16:
-	movswl	%ax, %eax
-	jmp	.Lretint
-
-.Lretuint8:
-	movzbl	%al, %eax
-	jmp	.Lretint
-
-.Lretuint16:
-	movzwl	%ax, %eax
-	jmp	.Lretint
-
-.Lretint:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        movl  %eax,0(%ecx)
-        jmp   .Lepilogue
- 
-.Lretfloat:
-         // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        fstps (%ecx)
-        jmp   .Lepilogue
- 
-.Lretdouble:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        fstpl (%ecx)
-        jmp   .Lepilogue
- 
-.Lretlongdouble:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        fstpt (%ecx)
-        jmp   .Lepilogue
- 
-.Lretint64:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        movl  %eax,0(%ecx)
-        movl  %edx,4(%ecx)
-	jmp   .Lepilogue
-
-.Lretstruct1b:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        movb  %al,0(%ecx)
-        jmp   .Lepilogue
- 
-.Lretstruct2b:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        movw  %ax,0(%ecx)
-        jmp   .Lepilogue
-
-.Lretstruct4b:
-        // Load %ecx with the pointer to storage for the return value
-        movl  28(%ebp),%ecx
-        movl  %eax,0(%ecx)
-        jmp   .Lepilogue
-
-.Lretstruct:
-        // Nothing to do!
- 
-.Lnoretval:
-.Lepilogue:
-        movl %ebp,%esp
-        popl %ebp
-        ret
-.ffi_call_win32_end:
-        .balign 16
-	.globl	_ffi_closure_THISCALL
-#ifndef __OS2__
-	.def	_ffi_closure_THISCALL;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_closure_THISCALL:
-	pushl	%ebp
-	movl	%esp, %ebp
-	subl	$40, %esp
-	leal	-24(%ebp), %edx
-	movl	%edx, -12(%ebp)	/* resp */
-	leal	12(%ebp), %edx  /* account for stub return address on stack */
-	jmp	.stub
-.LFE1:
-
-        // This assumes we are using gas.
-        .balign 16
-	.globl	_ffi_closure_SYSV
-#ifndef __OS2__
-	.def	_ffi_closure_SYSV;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_closure_SYSV:
-.LFB3:
-	pushl	%ebp
-.LCFI4:
-	movl	%esp, %ebp
-.LCFI5:
-	subl	$40, %esp
-	leal	-24(%ebp), %edx
-	movl	%edx, -12(%ebp)	/* resp */
-	leal	8(%ebp), %edx
-.stub:
-	movl	%edx, 4(%esp)	/* args = __builtin_dwarf_cfa () */
-	leal	-12(%ebp), %edx
-	movl	%edx, (%esp)	/* &resp */
-	call	_ffi_closure_SYSV_inner
-	movl	-12(%ebp), %ecx
-
-0:
-	call	1f
-	// Do not insert anything here between the call and the jump table.
-.Lcls_store_table:
-	.long	.Lcls_noretval		/* FFI_TYPE_VOID */
-	.long	.Lcls_retint		/* FFI_TYPE_INT */
-	.long	.Lcls_retfloat		/* FFI_TYPE_FLOAT */
-	.long	.Lcls_retdouble		/* FFI_TYPE_DOUBLE */
-	.long	.Lcls_retldouble	/* FFI_TYPE_LONGDOUBLE */
-	.long	.Lcls_retuint8		/* FFI_TYPE_UINT8 */
-	.long	.Lcls_retsint8		/* FFI_TYPE_SINT8 */
-	.long	.Lcls_retuint16		/* FFI_TYPE_UINT16 */
-	.long	.Lcls_retsint16		/* FFI_TYPE_SINT16 */
-	.long	.Lcls_retint		/* FFI_TYPE_UINT32 */
-	.long	.Lcls_retint		/* FFI_TYPE_SINT32 */
-	.long	.Lcls_retllong		/* FFI_TYPE_UINT64 */
-	.long	.Lcls_retllong		/* FFI_TYPE_SINT64 */
-	.long	.Lcls_retstruct		/* FFI_TYPE_STRUCT */
-	.long	.Lcls_retint		/* FFI_TYPE_POINTER */
-	.long	.Lcls_retstruct1	/* FFI_TYPE_SMALL_STRUCT_1B */
-	.long	.Lcls_retstruct2	/* FFI_TYPE_SMALL_STRUCT_2B */
-	.long	.Lcls_retstruct4	/* FFI_TYPE_SMALL_STRUCT_4B */
-	.long	.Lcls_retmsstruct	/* FFI_TYPE_MS_STRUCT */
-
-1:
-	add	%eax, %eax
-	add	%eax, %eax
-	add	(%esp),%eax
-	add	$4, %esp
-	jmp	*(%eax)
-
-	/* Sign/zero extend as appropriate.  */
-.Lcls_retsint8:
-	movsbl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retsint16:
-	movswl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retuint8:
-	movzbl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retuint16:
-	movzwl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retint:
-	movl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retfloat:
-	flds	(%ecx)
-	jmp	.Lcls_epilogue
-
-.Lcls_retdouble:
-	fldl	(%ecx)
-	jmp	.Lcls_epilogue
-
-.Lcls_retldouble:
-	fldt	(%ecx)
-	jmp	.Lcls_epilogue
-
-.Lcls_retllong:
-	movl	(%ecx), %eax
-	movl	4(%ecx), %edx
-	jmp	.Lcls_epilogue
-
-.Lcls_retstruct1:
-	movsbl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retstruct2:
-	movswl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retstruct4:
-	movl	(%ecx), %eax
-	jmp	.Lcls_epilogue
-
-.Lcls_retstruct:
-        // Caller expects us to pop struct return value pointer hidden arg.
-	movl	%ebp, %esp
-	popl	%ebp
-	ret	$0x4
-
-.Lcls_retmsstruct:
-	// Caller expects us to return a pointer to the real return value.
-	mov	%ecx, %eax
-	// Caller doesn't expects us to pop struct return value pointer hidden arg.
-	jmp	.Lcls_epilogue
-
-.Lcls_noretval:
-.Lcls_epilogue:
-	movl	%ebp, %esp
-	popl	%ebp
-	ret
-.ffi_closure_SYSV_end:
-.LFE3:
-
-#if !FFI_NO_RAW_API
-
-#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
-#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
-#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
-#define CIF_FLAGS_OFFSET 20
-        .balign 16
-	.globl	_ffi_closure_raw_THISCALL
-#ifndef __OS2__
-	.def	_ffi_closure_raw_THISCALL;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_closure_raw_THISCALL:
-	pushl	%ebp
-	movl	%esp, %ebp
-	pushl	%esi
-	subl	$36, %esp
-	movl	RAW_CLOSURE_CIF_OFFSET(%eax), %esi	 /* closure->cif */
-	movl	RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
-	movl	%edx, 12(%esp)	/* user_data */
-	leal	12(%ebp), %edx	/* __builtin_dwarf_cfa () */
-	jmp	.stubraw
-        // This assumes we are using gas.
-        .balign 16
-	.globl	_ffi_closure_raw_SYSV
-#ifndef __OS2__
-	.def	_ffi_closure_raw_SYSV;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_closure_raw_SYSV:
-.LFB4:
-	pushl	%ebp
-.LCFI6:
-	movl	%esp, %ebp
-.LCFI7:
-	pushl	%esi
-.LCFI8:
-	subl	$36, %esp
-	movl	RAW_CLOSURE_CIF_OFFSET(%eax), %esi	 /* closure->cif */
-	movl	RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
-	movl	%edx, 12(%esp)	/* user_data */
-	leal	8(%ebp), %edx	/* __builtin_dwarf_cfa () */
-.stubraw:
-	movl	%edx, 8(%esp)	/* raw_args */
-	leal	-24(%ebp), %edx
-	movl	%edx, 4(%esp)	/* &res */
-	movl	%esi, (%esp)	/* cif */
-	call	*RAW_CLOSURE_FUN_OFFSET(%eax)		 /* closure->fun */
-	movl	CIF_FLAGS_OFFSET(%esi), %eax		 /* rtype */
-0:
-	call	1f
-	// Do not insert anything here between the call and the jump table.
-.Lrcls_store_table:
-	.long	.Lrcls_noretval		/* FFI_TYPE_VOID */
-	.long	.Lrcls_retint		/* FFI_TYPE_INT */
-	.long	.Lrcls_retfloat		/* FFI_TYPE_FLOAT */
-	.long	.Lrcls_retdouble	/* FFI_TYPE_DOUBLE */
-	.long	.Lrcls_retldouble	/* FFI_TYPE_LONGDOUBLE */
-	.long	.Lrcls_retuint8		/* FFI_TYPE_UINT8 */
-	.long	.Lrcls_retsint8		/* FFI_TYPE_SINT8 */
-	.long	.Lrcls_retuint16	/* FFI_TYPE_UINT16 */
-	.long	.Lrcls_retsint16	/* FFI_TYPE_SINT16 */
-	.long	.Lrcls_retint		/* FFI_TYPE_UINT32 */
-	.long	.Lrcls_retint		/* FFI_TYPE_SINT32 */
-	.long	.Lrcls_retllong		/* FFI_TYPE_UINT64 */
-	.long	.Lrcls_retllong		/* FFI_TYPE_SINT64 */
-	.long	.Lrcls_retstruct	/* FFI_TYPE_STRUCT */
-	.long	.Lrcls_retint		/* FFI_TYPE_POINTER */
-	.long	.Lrcls_retstruct1	/* FFI_TYPE_SMALL_STRUCT_1B */
-	.long	.Lrcls_retstruct2	/* FFI_TYPE_SMALL_STRUCT_2B */
-	.long	.Lrcls_retstruct4	/* FFI_TYPE_SMALL_STRUCT_4B */
-	.long	.Lrcls_retstruct	/* FFI_TYPE_MS_STRUCT */
-1:
-	add	%eax, %eax
-	add	%eax, %eax
-	add	(%esp),%eax
-	add	$4, %esp
-	jmp	*(%eax)
-
-	/* Sign/zero extend as appropriate.  */
-.Lrcls_retsint8:
-	movsbl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retsint16:
-	movswl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retuint8:
-	movzbl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retuint16:
-	movzwl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retint:
-	movl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retfloat:
-	flds	-24(%ebp)
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retdouble:
-	fldl	-24(%ebp)
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retldouble:
-	fldt	-24(%ebp)
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retllong:
-	movl	-24(%ebp), %eax
-	movl	-20(%ebp), %edx
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retstruct1:
-	movsbl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retstruct2:
-	movswl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retstruct4:
-	movl	-24(%ebp), %eax
-	jmp	.Lrcls_epilogue
-
-.Lrcls_retstruct:
-	// Nothing to do!
-
-.Lrcls_noretval:
-.Lrcls_epilogue:
-	addl	$36, %esp
-	popl	%esi
-	popl	%ebp
-	ret
-.ffi_closure_raw_SYSV_end:
-.LFE4:
-
-#endif /* !FFI_NO_RAW_API */
-
-        // This assumes we are using gas.
-	.balign	16
-	.globl	_ffi_closure_STDCALL
-#ifndef __OS2__
-	.def	_ffi_closure_STDCALL;	.scl	2;	.type	32;	.endef
-#endif
-_ffi_closure_STDCALL:
-.LFB5:
-	pushl	%ebp
-.LCFI9:
-	movl	%esp, %ebp
-.LCFI10:
-	subl	$40, %esp
-	leal	-24(%ebp), %edx
-	movl	%edx, -12(%ebp)	/* resp */
-	leal	12(%ebp), %edx  /* account for stub return address on stack */
-	movl	%edx, 4(%esp)	/* args */
-	leal	-12(%ebp), %edx
-	movl	%edx, (%esp)	/* &resp */
-	call	_ffi_closure_SYSV_inner
-	movl	-12(%ebp), %ecx
-0:
-	call	1f
-	// Do not insert anything here between the call and the jump table.
-.Lscls_store_table:
-	.long	.Lscls_noretval		/* FFI_TYPE_VOID */
-	.long	.Lscls_retint		/* FFI_TYPE_INT */
-	.long	.Lscls_retfloat		/* FFI_TYPE_FLOAT */
-	.long	.Lscls_retdouble	/* FFI_TYPE_DOUBLE */
-	.long	.Lscls_retldouble	/* FFI_TYPE_LONGDOUBLE */
-	.long	.Lscls_retuint8		/* FFI_TYPE_UINT8 */
-	.long	.Lscls_retsint8		/* FFI_TYPE_SINT8 */
-	.long	.Lscls_retuint16	/* FFI_TYPE_UINT16 */
-	.long	.Lscls_retsint16	/* FFI_TYPE_SINT16 */
-	.long	.Lscls_retint		/* FFI_TYPE_UINT32 */
-	.long	.Lscls_retint		/* FFI_TYPE_SINT32 */
-	.long	.Lscls_retllong		/* FFI_TYPE_UINT64 */
-	.long	.Lscls_retllong		/* FFI_TYPE_SINT64 */
-	.long	.Lscls_retstruct	/* FFI_TYPE_STRUCT */
-	.long	.Lscls_retint		/* FFI_TYPE_POINTER */
-	.long	.Lscls_retstruct1	/* FFI_TYPE_SMALL_STRUCT_1B */
-	.long	.Lscls_retstruct2	/* FFI_TYPE_SMALL_STRUCT_2B */
-	.long	.Lscls_retstruct4	/* FFI_TYPE_SMALL_STRUCT_4B */
-1:
-	add	%eax, %eax
-	add	%eax, %eax
-	add	(%esp),%eax
-	add	$4, %esp
-	jmp	*(%eax)
-
-	/* Sign/zero extend as appropriate.  */
-.Lscls_retsint8:
-	movsbl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retsint16:
-	movswl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retuint8:
-	movzbl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retuint16:
-	movzwl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retint:
-	movl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retfloat:
-	flds	(%ecx)
-	jmp	.Lscls_epilogue
-
-.Lscls_retdouble:
-	fldl	(%ecx)
-	jmp	.Lscls_epilogue
-
-.Lscls_retldouble:
-	fldt	(%ecx)
-	jmp	.Lscls_epilogue
-
-.Lscls_retllong:
-	movl	(%ecx), %eax
-	movl	4(%ecx), %edx
-	jmp	.Lscls_epilogue
-
-.Lscls_retstruct1:
-	movsbl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retstruct2:
-	movswl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retstruct4:
-	movl	(%ecx), %eax
-	jmp	.Lscls_epilogue
-
-.Lscls_retstruct:
-	// Nothing to do!
-
-.Lscls_noretval:
-.Lscls_epilogue:
-	movl	%ebp, %esp
-	popl	%ebp
-	ret
-.ffi_closure_STDCALL_end:
-.LFE5:
-
-#ifndef __OS2__
-	.section	.eh_frame,"w"
-#endif
-.Lframe1:
-.LSCIE1:
-	.long	.LECIE1-.LASCIE1  /* Length of Common Information Entry */
-.LASCIE1:
-	.long	0x0	/* CIE Identifier Tag */
-	.byte	0x1	/* CIE Version */
-#ifdef __PIC__
-	.ascii "zR\0"	/* CIE Augmentation */
-#else
-	.ascii "\0"	/* CIE Augmentation */
-#endif
-	.byte	0x1	/* .uleb128 0x1; CIE Code Alignment Factor */
-	.byte	0x7c	/* .sleb128 -4; CIE Data Alignment Factor */
-	.byte	0x8	/* CIE RA Column */
-#ifdef __PIC__
-	.byte	0x1	/* .uleb128 0x1; Augmentation size */
-	.byte	0x1b	/* FDE Encoding (pcrel sdata4) */
-#endif
-	.byte	0xc	/* DW_CFA_def_cfa CFA = r4 + 4 = 4(%esp) */
-	.byte	0x4	/* .uleb128 0x4 */
-	.byte	0x4	/* .uleb128 0x4 */
-	.byte	0x88	/* DW_CFA_offset, column 0x8 %eip at CFA + 1 * -4 */
-	.byte	0x1	/* .uleb128 0x1 */
-	.align 4
-.LECIE1:
-
-.LSFDE1:
-	.long	.LEFDE1-.LASFDE1	/* FDE Length */
-.LASFDE1:
-	.long	.LASFDE1-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB1-.	/* FDE initial location */
-#else
-	.long	.LFB1
-#endif
-	.long	.LFE1-.LFB1	/* FDE address range */
-#ifdef __PIC__
-	.byte	0x0	/* .uleb128 0x0; Augmentation size */
-#endif
-	/* DW_CFA_xxx CFI instructions go here.  */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI0-.LFB1
-	.byte	0xe	/* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
-	.byte	0x8	/* .uleb128 0x8 */
-	.byte	0x85	/* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
-	.byte	0x2	/* .uleb128 0x2 */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI1-.LCFI0
-	.byte	0xd	/* DW_CFA_def_cfa_register CFA = r5 = %ebp */
-	.byte	0x5	/* .uleb128 0x5 */
-
-	/* End of DW_CFA_xxx CFI instructions.  */
-	.align 4
-.LEFDE1:
-
-
-.LSFDE3:
-	.long	.LEFDE3-.LASFDE3	/* FDE Length */
-.LASFDE3:
-	.long	.LASFDE3-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB3-.	/* FDE initial location */
-#else
-	.long	.LFB3
-#endif
-	.long	.LFE3-.LFB3	/* FDE address range */
-#ifdef __PIC__
-	.byte	0x0	/* .uleb128 0x0; Augmentation size */
-#endif
-	/* DW_CFA_xxx CFI instructions go here.  */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI4-.LFB3
-	.byte	0xe	/* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
-	.byte	0x8	/* .uleb128 0x8 */
-	.byte	0x85	/* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
-	.byte	0x2	/* .uleb128 0x2 */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI5-.LCFI4
-	.byte	0xd	/* DW_CFA_def_cfa_register CFA = r5 = %ebp */
-	.byte	0x5	/* .uleb128 0x5 */
-
-	/* End of DW_CFA_xxx CFI instructions.  */
-	.align 4
-.LEFDE3:
-
-#if !FFI_NO_RAW_API
-
-.LSFDE4:
-	.long	.LEFDE4-.LASFDE4	/* FDE Length */
-.LASFDE4:
-	.long	.LASFDE4-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB4-.	/* FDE initial location */
-#else
-	.long	.LFB4
-#endif
-	.long	.LFE4-.LFB4	/* FDE address range */
-#ifdef __PIC__
-	.byte	0x0	/* .uleb128 0x0; Augmentation size */
-#endif
-	/* DW_CFA_xxx CFI instructions go here.  */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI6-.LFB4
-	.byte	0xe	/* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
-	.byte	0x8	/* .uleb128 0x8 */
-	.byte	0x85	/* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
-	.byte	0x2	/* .uleb128 0x2 */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI7-.LCFI6
-	.byte	0xd	/* DW_CFA_def_cfa_register CFA = r5 = %ebp */
-	.byte	0x5	/* .uleb128 0x5 */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI8-.LCFI7
-	.byte	0x86	/* DW_CFA_offset, column 0x6 %esi at CFA + 3 * -4 */
-	.byte	0x3	/* .uleb128 0x3 */
-
-	/* End of DW_CFA_xxx CFI instructions.  */
-	.align 4
-.LEFDE4:
-
-#endif /* !FFI_NO_RAW_API */
-
-.LSFDE5:
-	.long	.LEFDE5-.LASFDE5	/* FDE Length */
-.LASFDE5:
-	.long	.LASFDE5-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB5-.	/* FDE initial location */
-#else
-	.long	.LFB5
-#endif
-	.long	.LFE5-.LFB5	/* FDE address range */
-#ifdef __PIC__
-	.byte	0x0	/* .uleb128 0x0; Augmentation size */
-#endif
-	/* DW_CFA_xxx CFI instructions go here.  */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI9-.LFB5
-	.byte	0xe	/* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
-	.byte	0x8	/* .uleb128 0x8 */
-	.byte	0x85	/* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
-	.byte	0x2	/* .uleb128 0x2 */
-
-	.byte	0x4	/* DW_CFA_advance_loc4 */
-	.long	.LCFI10-.LCFI9
-	.byte	0xd	/* DW_CFA_def_cfa_register CFA = r5 = %ebp */
-	.byte	0x5	/* .uleb128 0x5 */
-
-	/* End of DW_CFA_xxx CFI instructions.  */
-	.align 4
-.LEFDE5:
diff --git a/lib/wrappers/libffi/gcc/win32_asm.s b/lib/wrappers/libffi/gcc/win32_asm.s
deleted file mode 100644
index 7a3e7f16c..000000000
--- a/lib/wrappers/libffi/gcc/win32_asm.s
+++ /dev/null
@@ -1,736 +0,0 @@
-# 1 "gcc\\win32_asm.asm"

-# 1 "<command-line>"

-# 1 "gcc\\win32_asm.asm"

-# 33 "gcc\\win32_asm.asm"

-# 1 "common/fficonfig.h" 1

-# 34 "gcc\\win32_asm.asm" 2

-# 1 "common/ffi.h" 1

-# 63 "common/ffi.h"

-# 1 "common/ffitarget.h" 1

-# 64 "common/ffi.h" 2

-# 35 "gcc\\win32_asm.asm" 2

-

-

- .text

-

-

-        .balign 16

- .globl _ffi_call_win32

-

- .def _ffi_call_win32; .scl 2; .type 32; .endef

-

-_ffi_call_win32:

-.LFB1:

-        pushl %ebp

-.LCFI0:

-        movl %esp,%ebp

-.LCFI1:

-

-        movl 20(%ebp),%ecx

-        subl %ecx,%esp

-

-        movl %esp,%eax

-

-

-        pushl 12(%ebp)

-        pushl %eax

-        call *8(%ebp)

-

-

-        addl $8,%esp

-

-

- cmpl $3, 16(%ebp)

- jz .do_thiscall

- cmpl $4, 16(%ebp)

- jnz .do_fncall

- movl (%esp), %ecx

- movl 4(%esp), %edx

- addl $8, %esp

- jmp .do_fncall

-.do_thiscall:

- movl (%esp), %ecx

- addl $4, %esp

-

-.do_fncall:

-

-

-

-

-        call *32(%ebp)

-

-

-

-

-        movl 24(%ebp),%ecx

-

-

-        cmpl $0,28(%ebp)

-        jne 0f

-

-

-

-        cmpl $2,%ecx

-        jne .Lnoretval

-        fstp %st(0)

-

-        jmp .Lepilogue

-

-0:

- call 1f

-

-.Lstore_table:

- .long .Lnoretval

- .long .Lretint

- .long .Lretfloat

- .long .Lretdouble

- .long .Lretlongdouble

- .long .Lretuint8

- .long .Lretsint8

- .long .Lretuint16

- .long .Lretsint16

- .long .Lretint

- .long .Lretint

- .long .Lretint64

- .long .Lretint64

- .long .Lretstruct

- .long .Lretint

- .long .Lretstruct1b

- .long .Lretstruct2b

- .long .Lretstruct4b

- .long .Lretstruct

-1:

- add %ecx, %ecx

- add %ecx, %ecx

- add (%esp),%ecx

- add $4, %esp

- jmp *(%ecx)

-

-

-.Lretsint8:

- movsbl %al, %eax

- jmp .Lretint

-

-.Lretsint16:

- movswl %ax, %eax

- jmp .Lretint

-

-.Lretuint8:

- movzbl %al, %eax

- jmp .Lretint

-

-.Lretuint16:

- movzwl %ax, %eax

- jmp .Lretint

-

-.Lretint:

-

-        movl 28(%ebp),%ecx

-        movl %eax,0(%ecx)

-        jmp .Lepilogue

-

-.Lretfloat:

-

-        movl 28(%ebp),%ecx

-        fstps (%ecx)

-        jmp .Lepilogue

-

-.Lretdouble:

-

-        movl 28(%ebp),%ecx

-        fstpl (%ecx)

-        jmp .Lepilogue

-

-.Lretlongdouble:

-

-        movl 28(%ebp),%ecx

-        fstpt (%ecx)

-        jmp .Lepilogue

-

-.Lretint64:

-

-        movl 28(%ebp),%ecx

-        movl %eax,0(%ecx)

-        movl %edx,4(%ecx)

- jmp .Lepilogue

-

-.Lretstruct1b:

-

-        movl 28(%ebp),%ecx

-        movb %al,0(%ecx)

-        jmp .Lepilogue

-

-.Lretstruct2b:

-

-        movl 28(%ebp),%ecx

-        movw %ax,0(%ecx)

-        jmp .Lepilogue

-

-.Lretstruct4b:

-

-        movl 28(%ebp),%ecx

-        movl %eax,0(%ecx)

-        jmp .Lepilogue

-

-.Lretstruct:

-

-

-.Lnoretval:

-.Lepilogue:

-        movl %ebp,%esp

-        popl %ebp

-        ret

-.ffi_call_win32_end:

-        .balign 16

- .globl _ffi_closure_THISCALL

-

- .def _ffi_closure_THISCALL; .scl 2; .type 32; .endef

-

-_ffi_closure_THISCALL:

- pushl %ebp

- movl %esp, %ebp

- subl $40, %esp

- leal -24(%ebp), %edx

- movl %edx, -12(%ebp)

- leal 12(%ebp), %edx

- jmp .stub

-.LFE1:

-

-

-        .balign 16

- .globl _ffi_closure_SYSV

-

- .def _ffi_closure_SYSV; .scl 2; .type 32; .endef

-

-_ffi_closure_SYSV:

-.LFB3:

- pushl %ebp

-.LCFI4:

- movl %esp, %ebp

-.LCFI5:

- subl $40, %esp

- leal -24(%ebp), %edx

- movl %edx, -12(%ebp)

- leal 8(%ebp), %edx

-.stub:

- movl %edx, 4(%esp)

- leal -12(%ebp), %edx

- movl %edx, (%esp)

- call _ffi_closure_SYSV_inner

- movl -12(%ebp), %ecx

-

-0:

- call 1f

-

-.Lcls_store_table:

- .long .Lcls_noretval

- .long .Lcls_retint

- .long .Lcls_retfloat

- .long .Lcls_retdouble

- .long .Lcls_retldouble

- .long .Lcls_retuint8

- .long .Lcls_retsint8

- .long .Lcls_retuint16

- .long .Lcls_retsint16

- .long .Lcls_retint

- .long .Lcls_retint

- .long .Lcls_retllong

- .long .Lcls_retllong

- .long .Lcls_retstruct

- .long .Lcls_retint

- .long .Lcls_retstruct1

- .long .Lcls_retstruct2

- .long .Lcls_retstruct4

- .long .Lcls_retmsstruct

-

-1:

- add %eax, %eax

- add %eax, %eax

- add (%esp),%eax

- add $4, %esp

- jmp *(%eax)

-

-

-.Lcls_retsint8:

- movsbl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retsint16:

- movswl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retuint8:

- movzbl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retuint16:

- movzwl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retint:

- movl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retfloat:

- flds (%ecx)

- jmp .Lcls_epilogue

-

-.Lcls_retdouble:

- fldl (%ecx)

- jmp .Lcls_epilogue

-

-.Lcls_retldouble:

- fldt (%ecx)

- jmp .Lcls_epilogue

-

-.Lcls_retllong:

- movl (%ecx), %eax

- movl 4(%ecx), %edx

- jmp .Lcls_epilogue

-

-.Lcls_retstruct1:

- movsbl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retstruct2:

- movswl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retstruct4:

- movl (%ecx), %eax

- jmp .Lcls_epilogue

-

-.Lcls_retstruct:

-

- movl %ebp, %esp

- popl %ebp

- ret $0x4

-

-.Lcls_retmsstruct:

-

- mov %ecx, %eax

-

- jmp .Lcls_epilogue

-

-.Lcls_noretval:

-.Lcls_epilogue:

- movl %ebp, %esp

- popl %ebp

- ret

-.ffi_closure_SYSV_end:

-.LFE3:

-

-

-

-

-

-

-

-        .balign 16

- .globl _ffi_closure_raw_THISCALL

-

- .def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef

-

-_ffi_closure_raw_THISCALL:

- pushl %ebp

- movl %esp, %ebp

- pushl %esi

- subl $36, %esp

- movl ((52 + 3) & ~3)(%eax), %esi

- movl ((((52 + 3) & ~3) + 4) + 4)(%eax), %edx

- movl %edx, 12(%esp)

- leal 12(%ebp), %edx

- jmp .stubraw

-

-        .balign 16

- .globl _ffi_closure_raw_SYSV

-

- .def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef

-

-_ffi_closure_raw_SYSV:

-.LFB4:

- pushl %ebp

-.LCFI6:

- movl %esp, %ebp

-.LCFI7:

- pushl %esi

-.LCFI8:

- subl $36, %esp

- movl ((52 + 3) & ~3)(%eax), %esi

- movl ((((52 + 3) & ~3) + 4) + 4)(%eax), %edx

- movl %edx, 12(%esp)

- leal 8(%ebp), %edx

-.stubraw:

- movl %edx, 8(%esp)

- leal -24(%ebp), %edx

- movl %edx, 4(%esp)

- movl %esi, (%esp)

- call *(((52 + 3) & ~3) + 4)(%eax)

- movl 20(%esi), %eax

-0:

- call 1f

-

-.Lrcls_store_table:

- .long .Lrcls_noretval

- .long .Lrcls_retint

- .long .Lrcls_retfloat

- .long .Lrcls_retdouble

- .long .Lrcls_retldouble

- .long .Lrcls_retuint8

- .long .Lrcls_retsint8

- .long .Lrcls_retuint16

- .long .Lrcls_retsint16

- .long .Lrcls_retint

- .long .Lrcls_retint

- .long .Lrcls_retllong

- .long .Lrcls_retllong

- .long .Lrcls_retstruct

- .long .Lrcls_retint

- .long .Lrcls_retstruct1

- .long .Lrcls_retstruct2

- .long .Lrcls_retstruct4

- .long .Lrcls_retstruct

-1:

- add %eax, %eax

- add %eax, %eax

- add (%esp),%eax

- add $4, %esp

- jmp *(%eax)

-

-

-.Lrcls_retsint8:

- movsbl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retsint16:

- movswl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retuint8:

- movzbl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retuint16:

- movzwl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retint:

- movl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retfloat:

- flds -24(%ebp)

- jmp .Lrcls_epilogue

-

-.Lrcls_retdouble:

- fldl -24(%ebp)

- jmp .Lrcls_epilogue

-

-.Lrcls_retldouble:

- fldt -24(%ebp)

- jmp .Lrcls_epilogue

-

-.Lrcls_retllong:

- movl -24(%ebp), %eax

- movl -20(%ebp), %edx

- jmp .Lrcls_epilogue

-

-.Lrcls_retstruct1:

- movsbl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retstruct2:

- movswl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retstruct4:

- movl -24(%ebp), %eax

- jmp .Lrcls_epilogue

-

-.Lrcls_retstruct:

-

-

-.Lrcls_noretval:

-.Lrcls_epilogue:

- addl $36, %esp

- popl %esi

- popl %ebp

- ret

-.ffi_closure_raw_SYSV_end:

-.LFE4:

-

-

-

-

- .balign 16

- .globl _ffi_closure_STDCALL

-

- .def _ffi_closure_STDCALL; .scl 2; .type 32; .endef

-

-_ffi_closure_STDCALL:

-.LFB5:

- pushl %ebp

-.LCFI9:

- movl %esp, %ebp

-.LCFI10:

- subl $40, %esp

- leal -24(%ebp), %edx

- movl %edx, -12(%ebp)

- leal 12(%ebp), %edx

- movl %edx, 4(%esp)

- leal -12(%ebp), %edx

- movl %edx, (%esp)

- call _ffi_closure_SYSV_inner

- movl -12(%ebp), %ecx

-0:

- call 1f

-

-.Lscls_store_table:

- .long .Lscls_noretval

- .long .Lscls_retint

- .long .Lscls_retfloat

- .long .Lscls_retdouble

- .long .Lscls_retldouble

- .long .Lscls_retuint8

- .long .Lscls_retsint8

- .long .Lscls_retuint16

- .long .Lscls_retsint16

- .long .Lscls_retint

- .long .Lscls_retint

- .long .Lscls_retllong

- .long .Lscls_retllong

- .long .Lscls_retstruct

- .long .Lscls_retint

- .long .Lscls_retstruct1

- .long .Lscls_retstruct2

- .long .Lscls_retstruct4

-1:

- add %eax, %eax

- add %eax, %eax

- add (%esp),%eax

- add $4, %esp

- jmp *(%eax)

-

-

-.Lscls_retsint8:

- movsbl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retsint16:

- movswl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retuint8:

- movzbl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retuint16:

- movzwl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retint:

- movl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retfloat:

- flds (%ecx)

- jmp .Lscls_epilogue

-

-.Lscls_retdouble:

- fldl (%ecx)

- jmp .Lscls_epilogue

-

-.Lscls_retldouble:

- fldt (%ecx)

- jmp .Lscls_epilogue

-

-.Lscls_retllong:

- movl (%ecx), %eax

- movl 4(%ecx), %edx

- jmp .Lscls_epilogue

-

-.Lscls_retstruct1:

- movsbl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retstruct2:

- movswl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retstruct4:

- movl (%ecx), %eax

- jmp .Lscls_epilogue

-

-.Lscls_retstruct:

-

-

-.Lscls_noretval:

-.Lscls_epilogue:

- movl %ebp, %esp

- popl %ebp

- ret

-.ffi_closure_STDCALL_end:

-.LFE5:

-

-

- .section .eh_frame,"w"

-

-.Lframe1:

-.LSCIE1:

- .long .LECIE1-.LASCIE1

-.LASCIE1:

- .long 0x0

- .byte 0x1

-

-

-

- .ascii "\0"

-

- .byte 0x1

- .byte 0x7c

- .byte 0x8

-

-

-

-

- .byte 0xc

- .byte 0x4

- .byte 0x4

- .byte 0x88

- .byte 0x1

- .align 4

-.LECIE1:

-

-.LSFDE1:

- .long .LEFDE1-.LASFDE1

-.LASFDE1:

- .long .LASFDE1-.Lframe1

-

-

-

- .long .LFB1

-

- .long .LFE1-.LFB1

-

-

-

-

-

- .byte 0x4

- .long .LCFI0-.LFB1

- .byte 0xe

- .byte 0x8

- .byte 0x85

- .byte 0x2

-

- .byte 0x4

- .long .LCFI1-.LCFI0

- .byte 0xd

- .byte 0x5

-

-

- .align 4

-.LEFDE1:

-

-

-.LSFDE3:

- .long .LEFDE3-.LASFDE3

-.LASFDE3:

- .long .LASFDE3-.Lframe1

-

-

-

- .long .LFB3

-

- .long .LFE3-.LFB3

-

-

-

-

-

- .byte 0x4

- .long .LCFI4-.LFB3

- .byte 0xe

- .byte 0x8

- .byte 0x85

- .byte 0x2

-

- .byte 0x4

- .long .LCFI5-.LCFI4

- .byte 0xd

- .byte 0x5

-

-

- .align 4

-.LEFDE3:

-

-

-

-.LSFDE4:

- .long .LEFDE4-.LASFDE4

-.LASFDE4:

- .long .LASFDE4-.Lframe1

-

-

-

- .long .LFB4

-

- .long .LFE4-.LFB4

-

-

-

-

-

- .byte 0x4

- .long .LCFI6-.LFB4

- .byte 0xe

- .byte 0x8

- .byte 0x85

- .byte 0x2

-

- .byte 0x4

- .long .LCFI7-.LCFI6

- .byte 0xd

- .byte 0x5

-

- .byte 0x4

- .long .LCFI8-.LCFI7

- .byte 0x86

- .byte 0x3

-

-

- .align 4

-.LEFDE4:

-

-

-

-.LSFDE5:

- .long .LEFDE5-.LASFDE5

-.LASFDE5:

- .long .LASFDE5-.Lframe1

-

-

-

- .long .LFB5

-

- .long .LFE5-.LFB5

-

-

-

-

-

- .byte 0x4

- .long .LCFI9-.LFB5

- .byte 0xe

- .byte 0x8

- .byte 0x85

- .byte 0x2

-

- .byte 0x4

- .long .LCFI10-.LCFI9

- .byte 0xd

- .byte 0x5

-

-

- .align 4

-.LEFDE5:

diff --git a/lib/wrappers/libffi/gcc/win64_asm.asm b/lib/wrappers/libffi/gcc/win64_asm.asm
deleted file mode 100644
index 1dc98f99a..000000000
--- a/lib/wrappers/libffi/gcc/win64_asm.asm
+++ /dev/null
@@ -1,467 +0,0 @@
-#define LIBFFI_ASM
-#include <fficonfig.h>
-#include <ffi.h>
-	
-/* Constants for ffi_call_win64 */	
-#define STACK 0
-#define PREP_ARGS_FN 32
-#define ECIF 40
-#define CIF_BYTES 48
-#define CIF_FLAGS 56
-#define RVALUE 64
-#define FN 72
-
-/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
-                   extended_cif *ecif, unsigned bytes, unsigned flags,
-                   unsigned *rvalue, void (*fn)());
- */
-
-#ifdef _MSC_VER
-PUBLIC	ffi_call_win64
-
-EXTRN	__chkstk:NEAR
-EXTRN	ffi_closure_win64_inner:NEAR
-
-_TEXT	SEGMENT
-
-;;; ffi_closure_win64 will be called with these registers set:
-;;;    rax points to 'closure'
-;;;    r11 contains a bit mask that specifies which of the
-;;;    first four parameters are float or double
-;;;
-;;; It must move the parameters passed in registers to their stack location,
-;;; call ffi_closure_win64_inner for the actual work, then return the result.
-;;; 
-ffi_closure_win64 PROC FRAME
-	;; copy register arguments onto stack
-	test	r11, 1
-	jne	first_is_float	
-	mov	QWORD PTR [rsp+8], rcx
-	jmp	second
-first_is_float:
-	movlpd	QWORD PTR [rsp+8], xmm0
-
-second:
-	test	r11, 2
-	jne	second_is_float	
-	mov	QWORD PTR [rsp+16], rdx
-	jmp	third
-second_is_float:
-	movlpd	QWORD PTR [rsp+16], xmm1
-
-third:
-	test	r11, 4
-	jne	third_is_float	
-	mov	QWORD PTR [rsp+24], r8
-	jmp	fourth
-third_is_float:
-	movlpd	QWORD PTR [rsp+24], xmm2
-
-fourth:
-	test	r11, 8
-	jne	fourth_is_float	
-	mov	QWORD PTR [rsp+32], r9
-	jmp	done
-fourth_is_float:
-	movlpd	QWORD PTR [rsp+32], xmm3
-
-done:
-        .ALLOCSTACK 40
-	sub	rsp, 40
-        .ENDPROLOG
-	mov	rcx, rax	; context is first parameter
-	mov	rdx, rsp	; stack is second parameter
-	add	rdx, 48		; point to start of arguments
-	mov	rax, ffi_closure_win64_inner
-	call	rax		; call the real closure function
-	add	rsp, 40
-	movd	xmm0, rax	; If the closure returned a float,
-                                ; ffi_closure_win64_inner wrote it to rax
-	ret	0
-ffi_closure_win64 ENDP
-
-ffi_call_win64 PROC FRAME
-        ;; copy registers onto stack
-	mov	QWORD PTR [rsp+32], r9
-	mov	QWORD PTR [rsp+24], r8
-	mov	QWORD PTR [rsp+16], rdx
-	mov	QWORD PTR [rsp+8], rcx
-        .PUSHREG rbp
-	push	rbp
-        .ALLOCSTACK 48
-	sub	rsp, 48					; 00000030H
-        .SETFRAME rbp, 32
-	lea	rbp, QWORD PTR [rsp+32]
-        .ENDPROLOG
-
-	mov	eax, DWORD PTR CIF_BYTES[rbp]
-	add	rax, 15
-	and	rax, -16
-	call	__chkstk
-	sub	rsp, rax
-	lea	rax, QWORD PTR [rsp+32]
-	mov	QWORD PTR STACK[rbp], rax
-
-	mov	rdx, QWORD PTR ECIF[rbp]
-	mov	rcx, QWORD PTR STACK[rbp]
-	call	QWORD PTR PREP_ARGS_FN[rbp]
-
-	mov	rsp, QWORD PTR STACK[rbp]
-
-	movlpd	xmm3, QWORD PTR [rsp+24]
-	movd	r9, xmm3
-
-	movlpd	xmm2, QWORD PTR [rsp+16]
-	movd	r8, xmm2
-
-	movlpd	xmm1, QWORD PTR [rsp+8]
-	movd	rdx, xmm1
-
-	movlpd	xmm0, QWORD PTR [rsp]
-	movd	rcx, xmm0
-
-	call	QWORD PTR FN[rbp]
-ret_struct4b$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_4B
- 	jne	ret_struct2b$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	mov	DWORD PTR [rcx], eax
-	jmp	ret_void$
-
-ret_struct2b$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
- 	jne	ret_struct1b$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	mov	WORD PTR [rcx], ax
-	jmp	ret_void$
-
-ret_struct1b$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
- 	jne	ret_uint8$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	mov	BYTE PTR [rcx], al
-	jmp	ret_void$
-
-ret_uint8$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
- 	jne	ret_sint8$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	movzx   rax, al
-	mov	QWORD PTR [rcx], rax
-	jmp	ret_void$
-
-ret_sint8$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
- 	jne	ret_uint16$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	movsx   rax, al
-	mov	QWORD PTR [rcx], rax
-	jmp	ret_void$
-
-ret_uint16$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
- 	jne	ret_sint16$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	movzx   rax, ax
-	mov	QWORD PTR [rcx], rax
-	jmp	SHORT ret_void$
-
-ret_sint16$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16
- 	jne	ret_uint32$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	movsx   rax, ax
-	mov	QWORD PTR [rcx], rax
-	jmp	SHORT ret_void$
-
-ret_uint32$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32
- 	jne	ret_sint32$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	mov     eax, eax
-	mov	QWORD PTR [rcx], rax
-	jmp	SHORT ret_void$
-
-ret_sint32$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
- 	jne	ret_float$
-
-	mov	rcx, QWORD PTR RVALUE[rbp]
-	cdqe
-	mov	QWORD PTR [rcx], rax
-	jmp	SHORT ret_void$
-
-ret_float$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT
- 	jne	SHORT ret_double$
-
- 	mov	rax, QWORD PTR RVALUE[rbp]
- 	movss	DWORD PTR [rax], xmm0
- 	jmp	SHORT ret_void$
-
-ret_double$:
- 	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
- 	jne	SHORT ret_sint64$
-
- 	mov	rax, QWORD PTR RVALUE[rbp]
- 	movlpd	QWORD PTR [rax], xmm0
- 	jmp	SHORT ret_void$
-
-ret_sint64$:
-  	cmp	DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
-  	jne	ret_void$
-
- 	mov	rcx, QWORD PTR RVALUE[rbp]
- 	mov	QWORD PTR [rcx], rax
- 	jmp	SHORT ret_void$
-	
-ret_void$:
-	xor	rax, rax
-
-	lea	rsp, QWORD PTR [rbp+16]
-	pop	rbp
-	ret	0
-ffi_call_win64 ENDP
-_TEXT	ENDS
-END
-
-#else
-
-#ifdef SYMBOL_UNDERSCORE
-#define SYMBOL_NAME(name) _##name
-#else
-#define SYMBOL_NAME(name) name
-#endif
-
-.text
-
-.extern SYMBOL_NAME(ffi_closure_win64_inner)
-
-// ffi_closure_win64 will be called with these registers set:
-//    rax points to 'closure'
-//    r11 contains a bit mask that specifies which of the
-//    first four parameters are float or double
-// // It must move the parameters passed in registers to their stack location,
-// call ffi_closure_win64_inner for the actual work, then return the result.
-// 
-	.balign 16
-        .globl SYMBOL_NAME(ffi_closure_win64)
-SYMBOL_NAME(ffi_closure_win64):
-	// copy register arguments onto stack
-	test	$1,%r11
-	jne	.Lfirst_is_float	
-	mov	%rcx, 8(%rsp)
-	jmp	.Lsecond
-.Lfirst_is_float:
-	movlpd	%xmm0, 8(%rsp)
-
-.Lsecond:
-	test	$2, %r11
-	jne	.Lsecond_is_float	
-	mov	%rdx, 16(%rsp)
-	jmp	.Lthird
-.Lsecond_is_float:
-	movlpd	%xmm1, 16(%rsp)
-
-.Lthird:
-	test	$4, %r11
-	jne	.Lthird_is_float	
-	mov	%r8,24(%rsp)
-	jmp	.Lfourth
-.Lthird_is_float:
-	movlpd	%xmm2, 24(%rsp)
-
-.Lfourth:
-	test	$8, %r11
-	jne	.Lfourth_is_float	
-	mov	%r9, 32(%rsp)
-	jmp	.Ldone
-.Lfourth_is_float:
-	movlpd	%xmm3, 32(%rsp)
-
-.Ldone:
-// ALLOCSTACK 40
-	sub	$40, %rsp
-// ENDPROLOG
-	mov	%rax, %rcx	// context is first parameter
-	mov	%rsp, %rdx	// stack is second parameter
-	add	$48, %rdx	// point to start of arguments
-	mov	$SYMBOL_NAME(ffi_closure_win64_inner), %rax
-	callq	*%rax		// call the real closure function
-	add	$40, %rsp
-	movq	%rax, %xmm0	// If the closure returned a float,
-                                // ffi_closure_win64_inner wrote it to rax
-	retq
-.ffi_closure_win64_end:
-
-	.balign 16
-        .globl	SYMBOL_NAME(ffi_call_win64)
-SYMBOL_NAME(ffi_call_win64):
-        // copy registers onto stack
-	mov	%r9,32(%rsp)
-	mov	%r8,24(%rsp)
-	mov	%rdx,16(%rsp)
-	mov	%rcx,8(%rsp)
-        // PUSHREG rbp
-	push	%rbp
-        // ALLOCSTACK 48
-	sub	$48,%rsp
-        // SETFRAME rbp, 32
-	lea	32(%rsp),%rbp
-        // ENDPROLOG
-
-	mov	CIF_BYTES(%rbp),%eax
-	add	$15, %rax
-	and	$-16, %rax
-	cmpq	$0x1000, %rax
-	jb	Lch_done
-Lch_probe:
-	subq	$0x1000,%rsp
-	orl	$0x0, (%rsp)
-	subq	$0x1000,%rax
-	cmpq	$0x1000,%rax
-	ja	Lch_probe
-Lch_done:
-	subq	%rax, %rsp
-	orl	$0x0, (%rsp)
-	lea	32(%rsp), %rax
-	mov	%rax, STACK(%rbp)
-
-	mov	ECIF(%rbp), %rdx
-	mov	STACK(%rbp), %rcx
-	callq	*PREP_ARGS_FN(%rbp)
-
-	mov	STACK(%rbp), %rsp
-
-	movlpd	24(%rsp), %xmm3
-	movd	%xmm3, %r9
-
-	movlpd	16(%rsp), %xmm2
-	movd	%xmm2, %r8
-
-	movlpd	8(%rsp), %xmm1
-	movd	%xmm1, %rdx
-
-	movlpd	(%rsp), %xmm0
-	movd	%xmm0, %rcx
-
-	callq	*FN(%rbp)
-.Lret_struct4b:
- 	cmpl	$FFI_TYPE_SMALL_STRUCT_4B, CIF_FLAGS(%rbp)
- 	jne .Lret_struct2b
-
-	mov	RVALUE(%rbp), %rcx
-	mov	%eax, (%rcx)
-	jmp	.Lret_void
-
-.Lret_struct2b:
-	cmpl	$FFI_TYPE_SMALL_STRUCT_2B, CIF_FLAGS(%rbp)
-	jne .Lret_struct1b
-	
-	mov	RVALUE(%rbp), %rcx
-	mov	%ax, (%rcx)
-	jmp .Lret_void
-	
-.Lret_struct1b:
-	cmpl	$FFI_TYPE_SMALL_STRUCT_1B, CIF_FLAGS(%rbp)
-	jne .Lret_uint8
-	
-	mov	RVALUE(%rbp), %rcx
-	mov	%al, (%rcx)
-	jmp .Lret_void
-
-.Lret_uint8:
-	cmpl	$FFI_TYPE_UINT8, CIF_FLAGS(%rbp)
-	jne .Lret_sint8
-	
-        mov     RVALUE(%rbp), %rcx
-        movzbq  %al, %rax
-	movq    %rax, (%rcx)
-	jmp .Lret_void
-
-.Lret_sint8:
-	cmpl	$FFI_TYPE_SINT8, CIF_FLAGS(%rbp)
-	jne .Lret_uint16
-	
-        mov     RVALUE(%rbp), %rcx
-        movsbq  %al, %rax
-	movq    %rax, (%rcx)
-	jmp .Lret_void
-
-.Lret_uint16:
-	cmpl	$FFI_TYPE_UINT16, CIF_FLAGS(%rbp)
-	jne .Lret_sint16
-	
-        mov     RVALUE(%rbp), %rcx
-        movzwq  %ax, %rax
-	movq    %rax, (%rcx)
-	jmp .Lret_void
-
-.Lret_sint16:
-	cmpl	$FFI_TYPE_SINT16, CIF_FLAGS(%rbp)
-	jne .Lret_uint32
-	
-        mov     RVALUE(%rbp), %rcx
-        movswq  %ax, %rax
-	movq    %rax, (%rcx)
-	jmp .Lret_void
-
-.Lret_uint32:
-	cmpl	$FFI_TYPE_UINT32, CIF_FLAGS(%rbp)
-	jne .Lret_sint32
-	
-        mov     RVALUE(%rbp), %rcx
-        movl    %eax, %eax
-	movq    %rax, (%rcx)
-	jmp .Lret_void
-
-.Lret_sint32:
- 	cmpl	$FFI_TYPE_SINT32, CIF_FLAGS(%rbp)
- 	jne	.Lret_float
-
-	mov	RVALUE(%rbp), %rcx
-	cltq
-	movq	%rax, (%rcx)
-	jmp	.Lret_void
-
-.Lret_float:
- 	cmpl	$FFI_TYPE_FLOAT, CIF_FLAGS(%rbp)
- 	jne	.Lret_double
-
- 	mov	RVALUE(%rbp), %rax
- 	movss	%xmm0, (%rax)
- 	jmp	.Lret_void
-
-.Lret_double:
- 	cmpl	$FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
- 	jne	.Lret_sint64
-
- 	mov	RVALUE(%rbp), %rax
- 	movlpd	%xmm0, (%rax)
- 	jmp	.Lret_void
-
-.Lret_sint64:
-  	cmpl	$FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
-  	jne	.Lret_void
-
- 	mov	RVALUE(%rbp), %rcx
- 	mov	%rax, (%rcx)
- 	jmp	.Lret_void
-	
-.Lret_void:
-	xor	%rax, %rax
-
-	lea	16(%rbp), %rsp
-	pop	%rbp
-	retq
-.ffi_call_win64_end:
-#endif /* !_MSC_VER */
-
diff --git a/lib/wrappers/libffi/gcc/win64_asm.s b/lib/wrappers/libffi/gcc/win64_asm.s
deleted file mode 100644
index f2c2df10d..000000000
--- a/lib/wrappers/libffi/gcc/win64_asm.s
+++ /dev/null
@@ -1,227 +0,0 @@
-# 1 "gcc\\win64_asm.asm"

-# 1 "<command-line>"

-# 1 "gcc\\win64_asm.asm"

-

-# 1 "common/fficonfig.h" 1

-# 3 "gcc\\win64_asm.asm" 2

-# 1 "common/ffi.h" 1

-# 63 "common/ffi.h"

-# 1 "common/ffitarget.h" 1

-# 64 "common/ffi.h" 2

-# 4 "gcc\\win64_asm.asm" 2

-# 244 "gcc\\win64_asm.asm"

-.text

-

-.extern ffi_closure_win64_inner

-# 255 "gcc\\win64_asm.asm"

- .balign 16

-        .globl ffi_closure_win64

-ffi_closure_win64:

-

- test $1,%r11

- jne .Lfirst_is_float

- mov %rcx, 8(%rsp)

- jmp .Lsecond

-.Lfirst_is_float:

- movlpd %xmm0, 8(%rsp)

-

-.Lsecond:

- test $2, %r11

- jne .Lsecond_is_float

- mov %rdx, 16(%rsp)

- jmp .Lthird

-.Lsecond_is_float:

- movlpd %xmm1, 16(%rsp)

-

-.Lthird:

- test $4, %r11

- jne .Lthird_is_float

- mov %r8,24(%rsp)

- jmp .Lfourth

-.Lthird_is_float:

- movlpd %xmm2, 24(%rsp)

-

-.Lfourth:

- test $8, %r11

- jne .Lfourth_is_float

- mov %r9, 32(%rsp)

- jmp .Ldone

-.Lfourth_is_float:

- movlpd %xmm3, 32(%rsp)

-

-.Ldone:

-

- sub $40, %rsp

-

- mov %rax, %rcx

- mov %rsp, %rdx

- add $48, %rdx

- mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax

- callq *%rax

- add $40, %rsp

- movq %rax, %xmm0

-

- retq

-.ffi_closure_win64_end:

-

- .balign 16

-        .globl ffi_call_win64

-ffi_call_win64:

-

- mov %r9,32(%rsp)

- mov %r8,24(%rsp)

- mov %rdx,16(%rsp)

- mov %rcx,8(%rsp)

-

- push %rbp

-

- sub $48,%rsp

-

- lea 32(%rsp),%rbp

-

-

- mov 48(%rbp),%eax

- add $15, %rax

- and $-16, %rax

- cmpq $0x1000, %rax

- jb Lch_done

-Lch_probe:

- subq $0x1000,%rsp

- orl $0x0, (%rsp)

- subq $0x1000,%rax

- cmpq $0x1000,%rax

- ja Lch_probe

-Lch_done:

- subq %rax, %rsp

- orl $0x0, (%rsp)

- lea 32(%rsp), %rax

- mov %rax, 0(%rbp)

-

- mov 40(%rbp), %rdx

- mov 0(%rbp), %rcx

- callq *32(%rbp)

-

- mov 0(%rbp), %rsp

-

- movlpd 24(%rsp), %xmm3

- movd %xmm3, %r9

-

- movlpd 16(%rsp), %xmm2

- movd %xmm2, %r8

-

- movlpd 8(%rsp), %xmm1

- movd %xmm1, %rdx

-

- movlpd (%rsp), %xmm0

- movd %xmm0, %rcx

-

- callq *72(%rbp)

-.Lret_struct4b:

-  cmpl $FFI_TYPE_SMALL_STRUCT_4B, 56(%rbp)

-  jne .Lret_struct2b

-

- mov 64(%rbp), %rcx

- mov %eax, (%rcx)

- jmp .Lret_void

-

-.Lret_struct2b:

- cmpl $FFI_TYPE_SMALL_STRUCT_2B, 56(%rbp)

- jne .Lret_struct1b

-

- mov 64(%rbp), %rcx

- mov %ax, (%rcx)

- jmp .Lret_void

-

-.Lret_struct1b:

- cmpl $FFI_TYPE_SMALL_STRUCT_1B, 56(%rbp)

- jne .Lret_uint8

-

- mov 64(%rbp), %rcx

- mov %al, (%rcx)

- jmp .Lret_void

-

-.Lret_uint8:

- cmpl $FFI_TYPE_UINT8, 56(%rbp)

- jne .Lret_sint8

-

-        mov 64(%rbp), %rcx

-        movzbq %al, %rax

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_sint8:

- cmpl $FFI_TYPE_SINT8, 56(%rbp)

- jne .Lret_uint16

-

-        mov 64(%rbp), %rcx

-        movsbq %al, %rax

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_uint16:

- cmpl $FFI_TYPE_UINT16, 56(%rbp)

- jne .Lret_sint16

-

-        mov 64(%rbp), %rcx

-        movzwq %ax, %rax

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_sint16:

- cmpl $FFI_TYPE_SINT16, 56(%rbp)

- jne .Lret_uint32

-

-        mov 64(%rbp), %rcx

-        movswq %ax, %rax

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_uint32:

- cmpl $9, 56(%rbp)

- jne .Lret_sint32

-

-        mov 64(%rbp), %rcx

-        movl %eax, %eax

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_sint32:

-  cmpl $10, 56(%rbp)

-  jne .Lret_float

-

- mov 64(%rbp), %rcx

- cltq

- movq %rax, (%rcx)

- jmp .Lret_void

-

-.Lret_float:

-  cmpl $2, 56(%rbp)

-  jne .Lret_double

-

-  mov 64(%rbp), %rax

-  movss %xmm0, (%rax)

-  jmp .Lret_void

-

-.Lret_double:

-  cmpl $3, 56(%rbp)

-  jne .Lret_sint64

-

-  mov 64(%rbp), %rax

-  movlpd %xmm0, (%rax)

-  jmp .Lret_void

-

-.Lret_sint64:

-   cmpl $12, 56(%rbp)

-   jne .Lret_void

-

-  mov 64(%rbp), %rcx

-  mov %rax, (%rcx)

-  jmp .Lret_void

-

-.Lret_void:

- xor %rax, %rax

-

- lea 16(%rbp), %rsp

- pop %rbp

- retq

-.ffi_call_win64_end:

diff --git a/lib/wrappers/libffi/libffi.nim b/lib/wrappers/libffi/libffi.nim
deleted file mode 100644
index 34b91f8c7..000000000
--- a/lib/wrappers/libffi/libffi.nim
+++ /dev/null
@@ -1,176 +0,0 @@
-# -----------------------------------------------------------------*-C-*-
-#   libffi 3.0.10 - Copyright (c) 2011 Anthony Green
-#                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
-#
-#   Permission is hereby granted, free of charge, to any person
-#   obtaining a copy of this software and associated documentation
-#   files (the ``Software''), to deal in the Software without
-#   restriction, including without limitation the rights to use, copy,
-#   modify, merge, publish, distribute, sublicense, and/or sell copies
-#   of the Software, and to permit persons to whom the Software is
-#   furnished to do so, subject to the following conditions:
-#
-#   The above copyright notice and this permission notice shall be
-#   included in all copies or substantial portions of the Software.
-#
-#   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-#   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-#   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-#   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-#   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-#   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-#   DEALINGS IN THE SOFTWARE.
-#
-#   ----------------------------------------------------------------------- 
-
-{.deadCodeElim: on.}
-
-when defined(windows):
-  # on Windows we don't use a DLL but instead embed libffi directly:
-  {.pragma: mylib, header: r"ffi.h".}
-
-  #{.compile: r"common\malloc_closure.c".}
-  {.compile: r"common\raw_api.c".}
-  when defined(vcc):
-    {.compile: r"msvc\ffi.c".}
-    {.compile: r"msvc\prep_cif.c".}
-    {.compile: r"msvc\win32.c".}
-    {.compile: r"msvc\types.c".}
-    when defined(cpu64):
-      {.compile: r"msvc\win64_asm.asm".}
-    else:
-      {.compile: r"msvc\win32_asm.asm".}
-  else:
-    {.compile: r"gcc\ffi.c".}
-    {.compile: r"gcc\prep_cif.c".}
-    {.compile: r"gcc\types.c".}
-    {.compile: r"gcc\closures.c".}
-    when defined(cpu64):
-      {.compile: r"gcc\ffi64.c".}
-      {.compile: r"gcc\win64_asm.S".}
-    else:
-      {.compile: r"gcc\win32_asm.S".}
-
-elif defined(macosx):
-  {.pragma: mylib, dynlib: "libffi.dylib".}
-else:
-  {.pragma: mylib, dynlib: "libffi.so".}
-
-type
-  Arg* = int
-  SArg* = int
-{.deprecated: [TArg: Arg, TSArg: SArg].}
-
-when defined(windows) and defined(x86):
-  type
-    TABI* {.size: sizeof(cint).} = enum
-      FIRST_ABI, SYSV, STDCALL
-
-  const DEFAULT_ABI* = SYSV
-elif defined(amd64) and defined(windows):
-  type 
-    TABI* {.size: sizeof(cint).} = enum 
-      FIRST_ABI, WIN64
-  const DEFAULT_ABI* = WIN64
-else:
-  type 
-    TABI* {.size: sizeof(cint).} = enum
-      FIRST_ABI, SYSV, UNIX64
-
-  when defined(i386):
-    const DEFAULT_ABI* = SYSV
-  else: 
-    const DEFAULT_ABI* = UNIX64
-    
-const 
-  tkVOID* = 0
-  tkINT* = 1
-  tkFLOAT* = 2
-  tkDOUBLE* = 3
-  tkLONGDOUBLE* = 4
-  tkUINT8* = 5
-  tkSINT8* = 6
-  tkUINT16* = 7
-  tkSINT16* = 8
-  tkUINT32* = 9
-  tkSINT32* = 10
-  tkUINT64* = 11
-  tkSINT64* = 12
-  tkSTRUCT* = 13
-  tkPOINTER* = 14
-
-  tkLAST = tkPOINTER
-  tkSMALL_STRUCT_1B* = (tkLAST + 1)
-  tkSMALL_STRUCT_2B* = (tkLAST + 2)
-  tkSMALL_STRUCT_4B* = (tkLAST + 3)
-
-type
-  Type* = object
-    size*: int
-    alignment*: uint16
-    typ*: uint16
-    elements*: ptr ptr Type
-{.deprecated: [TType: Type].}
-
-var
-  type_void* {.importc: "ffi_type_void", mylib.}: Type
-  type_uint8* {.importc: "ffi_type_uint8", mylib.}: Type
-  type_sint8* {.importc: "ffi_type_sint8", mylib.}: Type
-  type_uint16* {.importc: "ffi_type_uint16", mylib.}: Type
-  type_sint16* {.importc: "ffi_type_sint16", mylib.}: Type
-  type_uint32* {.importc: "ffi_type_uint32", mylib.}: Type
-  type_sint32* {.importc: "ffi_type_sint32", mylib.}: Type
-  type_uint64* {.importc: "ffi_type_uint64", mylib.}: Type
-  type_sint64* {.importc: "ffi_type_sint64", mylib.}: Type
-  type_float* {.importc: "ffi_type_float", mylib.}: Type
-  type_double* {.importc: "ffi_type_double", mylib.}: Type
-  type_pointer* {.importc: "ffi_type_pointer", mylib.}: Type
-  type_longdouble* {.importc: "ffi_type_longdouble", mylib.}: Type
-
-type 
-  Status* {.size: sizeof(cint).} = enum 
-    OK, BAD_TYPEDEF, BAD_ABI
-  TypeKind* = cuint
-  TCif* {.pure, final.} = object 
-    abi*: TABI
-    nargs*: cuint
-    arg_types*: ptr ptr Type
-    rtype*: ptr Type
-    bytes*: cuint
-    flags*: cuint
-{.deprecated: [Tstatus: Status].}
-
-type
-  Raw* = object 
-    sint*: SArg
-{.deprecated: [TRaw: Raw].}
-
-proc raw_call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer; 
-               avalue: ptr Raw) {.cdecl, importc: "ffi_raw_call", mylib.}
-proc ptrarray_to_raw*(cif: var Tcif; args: ptr pointer; raw: ptr Raw) {.cdecl, 
-    importc: "ffi_ptrarray_to_raw", mylib.}
-proc raw_to_ptrarray*(cif: var Tcif; raw: ptr Raw; args: ptr pointer) {.cdecl, 
-    importc: "ffi_raw_to_ptrarray", mylib.}
-proc raw_size*(cif: var Tcif): int {.cdecl, importc: "ffi_raw_size", mylib.}
-
-proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type; 
-               atypes: ptr ptr Type): Status {.cdecl, importc: "ffi_prep_cif", 
-    mylib.}
-proc call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer; 
-           avalue: ptr pointer) {.cdecl, importc: "ffi_call", mylib.}
-
-# the same with an easier interface:
-type
-  ParamList* = array[0..100, ptr Type]
-  ArgList* = array[0..100, pointer]
-{.deprecated: [TParamList: ParamList, TArgList: ArgList].}
-
-proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type; 
-               atypes: ParamList): Status {.cdecl, importc: "ffi_prep_cif",
-    mylib.}
-proc call*(cif: var Tcif; fn, rvalue: pointer;
-           avalue: ArgList) {.cdecl, importc: "ffi_call", mylib.}
-
-# Useful for eliminating compiler warnings 
-##define FFI_FN(f) ((void (*)(void))f)
diff --git a/lib/wrappers/libffi/msvc/ffi.c b/lib/wrappers/libffi/msvc/ffi.c
deleted file mode 100644
index 6e595e9fe..000000000
--- a/lib/wrappers/libffi/msvc/ffi.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996, 1998, 1999, 2001  Red Hat, Inc.
-           Copyright (c) 2002  Ranjit Mathew
-           Copyright (c) 2002  Bo Thorsen
-           Copyright (c) 2002  Roger Sayle
-   
-   x86 Foreign Function Interface 
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-
-/* ffi_prep_args is called by the assembly routine once stack space
-   has been allocated for the function's arguments */
-
-extern void Py_FatalError(const char *msg);
-
-/*@-exportheader@*/
-void ffi_prep_args(char *stack, extended_cif *ecif)
-/*@=exportheader@*/
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-  if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
-    {
-      *(void **) argp = ecif->rvalue;
-      argp += sizeof(void *);
-    }
-
-  p_argv = ecif->avalue;
-
-  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
-       i != 0;
-       i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(void *) - 1) & (size_t) argp)
-	argp = (char *) ALIGN(argp, sizeof(void *));
-
-      z = (*p_arg)->size;
-      if (z < sizeof(int))
-	{
-	  z = sizeof(int);
-	  switch ((*p_arg)->type)
-	    {
-	    case FFI_TYPE_SINT8:
-	      *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT8:
-	      *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_SINT16:
-	      *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT16:
-	      *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_SINT32:
-	      *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_UINT32:
-	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
-	      break;
-
-	    case FFI_TYPE_STRUCT:
-	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
-	      break;
-
-	    default:
-	      FFI_ASSERT(0);
-	    }
-	}
-      else
-	{
-	  memcpy(argp, *p_argv, z);
-	}
-      p_argv++;
-      argp += z;
-    }
-
-  if (argp >= stack && (unsigned)(argp - stack) > ecif->cif->bytes) 
-    {
-      Py_FatalError("FFI BUG: not enough stack space for arguments");
-    }
-  return;
-}
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
-{
-  /* Set the return type flag */
-  switch (cif->rtype->type)
-    {
-    case FFI_TYPE_VOID:
-    case FFI_TYPE_STRUCT:
-    case FFI_TYPE_SINT64:
-    case FFI_TYPE_FLOAT:
-    case FFI_TYPE_DOUBLE:
-    case FFI_TYPE_LONGDOUBLE:
-      cif->flags = (unsigned) cif->rtype->type;
-      break;
-
-    case FFI_TYPE_UINT64:
-#ifdef _WIN64
-    case FFI_TYPE_POINTER:
-#endif
-      cif->flags = FFI_TYPE_SINT64;
-      break;
-
-    default:
-      cif->flags = FFI_TYPE_INT;
-      break;
-    }
-
-  return FFI_OK;
-}
-
-#ifdef _WIN32
-extern int
-ffi_call_x86(void (*)(char *, extended_cif *), 
-	     /*@out@*/ extended_cif *, 
-	     unsigned, unsigned, 
-	     /*@out@*/ unsigned *, 
-	     void (*fn)());
-#endif
-
-#ifdef _WIN64
-extern int
-ffi_call_AMD64(void (*)(char *, extended_cif *),
-		 /*@out@*/ extended_cif *,
-		 unsigned, unsigned,
-		 /*@out@*/ unsigned *,
-		 void (*fn)());
-#endif
-
-int
-ffi_call(/*@dependent@*/ ffi_cif *cif, 
-	 void (*fn)(), 
-	 /*@out@*/ void *rvalue, 
-	 /*@dependent@*/ void **avalue)
-{
-  extended_cif ecif;
-
-  ecif.cif = cif;
-  ecif.avalue = avalue;
-  
-  /* If the return value is a struct and we don't have a return	*/
-  /* value address then we need to make one		        */
-
-  if ((rvalue == NULL) && 
-      (cif->rtype->type == FFI_TYPE_STRUCT))
-    {
-      /*@-sysunrecog@*/
-      ecif.rvalue = alloca(cif->rtype->size);
-      /*@=sysunrecog@*/
-    }
-  else
-    ecif.rvalue = rvalue;
-    
-  
-  switch (cif->abi) 
-    {
-#if !defined(_WIN64)
-    case FFI_SYSV:
-    case FFI_STDCALL:
-      return ffi_call_x86(ffi_prep_args, &ecif, cif->bytes, 
-			  cif->flags, ecif.rvalue, fn);
-      break;
-#else
-    case FFI_SYSV:
-      /*@-usedef@*/
-      /* Function call needs at least 40 bytes stack size, on win64 AMD64 */
-      return ffi_call_AMD64(ffi_prep_args, &ecif, cif->bytes ? cif->bytes : 40,
-			   cif->flags, ecif.rvalue, fn);
-      /*@=usedef@*/
-      break;
-#endif
-
-    default:
-      FFI_ASSERT(0);
-      break;
-    }
-  return -1; /* theller: Hrm. */
-}
-
-
-/** private members **/
-
-static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
-					  void** args, ffi_cif* cif);
-/* This function is jumped to by the trampoline */
-
-#ifdef _WIN64
-void *
-#else
-static void __fastcall
-#endif
-ffi_closure_SYSV (ffi_closure *closure, int *argp)
-{
-  // this is our return value storage
-  long double    res;
-
-  // our various things...
-  ffi_cif       *cif;
-  void         **arg_area;
-  unsigned short rtype;
-  void          *resp = (void*)&res;
-  void *args = &argp[1];
-
-  cif         = closure->cif;
-  arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
-
-  /* this call will initialize ARG_AREA, such that each
-   * element in that array points to the corresponding 
-   * value on the stack; and if the function returns
-   * a structure, it will re-set RESP to point to the
-   * structure return address.  */
-
-  ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif);
-  
-  (closure->fun) (cif, resp, arg_area, closure->user_data);
-
-  rtype = cif->flags;
-
-#if defined(_WIN32) && !defined(_WIN64)
-#ifdef _MSC_VER
-  /* now, do a generic return based on the value of rtype */
-  if (rtype == FFI_TYPE_INT)
-    {
-	    _asm mov eax, resp ;
-	    _asm mov eax, [eax] ;
-    }
-  else if (rtype == FFI_TYPE_FLOAT)
-    {
-	    _asm mov eax, resp ;
-	    _asm fld DWORD PTR [eax] ;
-//      asm ("flds (%0)" : : "r" (resp) : "st" );
-    }
-  else if (rtype == FFI_TYPE_DOUBLE)
-    {
-	    _asm mov eax, resp ;
-	    _asm fld QWORD PTR [eax] ;
-//      asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_LONGDOUBLE)
-    {
-//      asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_SINT64)
-    {
-	    _asm mov edx, resp ;
-	    _asm mov eax, [edx] ;
-	    _asm mov edx, [edx + 4] ;
-//      asm ("movl 0(%0),%%eax;"
-//	   "movl 4(%0),%%edx" 
-//	   : : "r"(resp)
-//	   : "eax", "edx");
-    }
-#else
-  /* now, do a generic return based on the value of rtype */
-  if (rtype == FFI_TYPE_INT)
-    {
-      asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
-    }
-  else if (rtype == FFI_TYPE_FLOAT)
-    {
-      asm ("flds (%0)" : : "r" (resp) : "st" );
-    }
-  else if (rtype == FFI_TYPE_DOUBLE)
-    {
-      asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_LONGDOUBLE)
-    {
-      asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
-    }
-  else if (rtype == FFI_TYPE_SINT64)
-    {
-      asm ("movl 0(%0),%%eax;"
-	   "movl 4(%0),%%edx" 
-	   : : "r"(resp)
-	   : "eax", "edx");
-    }
-#endif
-#endif
-
-#ifdef _WIN64
-  /* The result is returned in rax.  This does the right thing for
-     result types except for floats; we have to 'mov xmm0, rax' in the
-     caller to correct this.
-  */
-  return *(void **)resp;
-#endif
-}
-
-/*@-exportheader@*/
-static void 
-ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
-			    void **avalue, ffi_cif *cif)
-/*@=exportheader@*/
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-
-  if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
-    *rvalue = *(void **) argp;
-    argp += 4;
-  }
-
-  p_argv = avalue;
-
-  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
-    {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(char *) - 1) & (size_t) argp) {
-	argp = (char *) ALIGN(argp, sizeof(char*));
-      }
-
-      z = (*p_arg)->size;
-
-      /* because we're little endian, this is what it turns into.   */
-
-      *p_argv = (void*) argp;
-
-      p_argv++;
-      argp += z;
-    }
-  
-  return;
-}
-
-/* the cif must already be prep'ed */
-extern void ffi_closure_OUTER();
-
-ffi_status
-ffi_prep_closure_loc (ffi_closure* closure,
-					  ffi_cif* cif,
-					  void (*fun)(ffi_cif*,void*,void**,void*),
-					  void *user_data,
-					  void *codeloc)
-{
-  short bytes;
-  char *tramp;
-#ifdef _WIN64
-  int mask = 0;
-#endif
-  FFI_ASSERT (cif->abi == FFI_SYSV);
-  
-  if (cif->abi == FFI_SYSV)
-    bytes = 0;
-#if !defined(_WIN64)
-  else if (cif->abi == FFI_STDCALL)
-    bytes = cif->bytes;
-#endif
-  else
-    return FFI_BAD_ABI;
-
-  tramp = &closure->tramp[0];
-
-#define BYTES(text) memcpy(tramp, text, sizeof(text)), tramp += sizeof(text)-1
-#define POINTER(x) *(void**)tramp = (void*)(x), tramp += sizeof(void*)
-#define SHORT(x) *(short*)tramp = x, tramp += sizeof(short)
-#define INT(x) *(int*)tramp = x, tramp += sizeof(int)
-
-#ifdef _WIN64
-  if (cif->nargs >= 1 &&
-      (cif->arg_types[0]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[0]->type == FFI_TYPE_DOUBLE))
-    mask |= 1;
-  if (cif->nargs >= 2 &&
-      (cif->arg_types[1]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[1]->type == FFI_TYPE_DOUBLE))
-    mask |= 2;
-  if (cif->nargs >= 3 &&
-      (cif->arg_types[2]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[2]->type == FFI_TYPE_DOUBLE))
-    mask |= 4;
-  if (cif->nargs >= 4 &&
-      (cif->arg_types[3]->type == FFI_TYPE_FLOAT
-       || cif->arg_types[3]->type == FFI_TYPE_DOUBLE))
-    mask |= 8;
-
-  /* 41 BB ----         mov         r11d,mask */
-  BYTES("\x41\xBB"); INT(mask);
-
-  /* 48 B8 --------     mov         rax, closure			*/
-  BYTES("\x48\xB8"); POINTER(closure);
-
-  /* 49 BA --------     mov         r10, ffi_closure_OUTER */
-  BYTES("\x49\xBA"); POINTER(ffi_closure_OUTER);
-
-  /* 41 FF E2           jmp         r10 */
-  BYTES("\x41\xFF\xE2");
-
-#else
-
-  /* mov ecx, closure */
-  BYTES("\xb9"); POINTER(closure);
-
-  /* mov edx, esp */
-  BYTES("\x8b\xd4");
-
-  /* call ffi_closure_SYSV */
-  BYTES("\xe8"); POINTER((char*)&ffi_closure_SYSV - (tramp + 4));
-
-  /* ret bytes */
-  BYTES("\xc2");
-  SHORT(bytes);
-  
-#endif
-
-  if (tramp - &closure->tramp[0] > FFI_TRAMPOLINE_SIZE)
-    Py_FatalError("FFI_TRAMPOLINE_SIZE too small in " __FILE__);
-
-  closure->cif  = cif;
-  closure->user_data = user_data;
-  closure->fun  = fun;
-  return FFI_OK;
-}
diff --git a/lib/wrappers/libffi/msvc/prep_cif.c b/lib/wrappers/libffi/msvc/prep_cif.c
deleted file mode 100644
index 2650fa052..000000000
--- a/lib/wrappers/libffi/msvc/prep_cif.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -----------------------------------------------------------------------
-   prep_cif.c - Copyright (c) 1996, 1998  Red Hat, Inc.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-#include <stdlib.h>
-
-
-/* Round up to FFI_SIZEOF_ARG. */
-
-#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
-
-/* Perform machine independent initialization of aggregate type
-   specifications. */
-
-static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
-{
-  ffi_type **ptr; 
-
-  FFI_ASSERT(arg != NULL);
-
-  /*@-usedef@*/
-
-  FFI_ASSERT(arg->elements != NULL);
-  FFI_ASSERT(arg->size == 0);
-  FFI_ASSERT(arg->alignment == 0);
-
-  ptr = &(arg->elements[0]);
-
-  while ((*ptr) != NULL)
-    {
-      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
-	return FFI_BAD_TYPEDEF;
-      
-      /* Perform a sanity check on the argument type */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-      arg->size = ALIGN(arg->size, (*ptr)->alignment);
-      arg->size += (*ptr)->size;
-
-      arg->alignment = (arg->alignment > (*ptr)->alignment) ? 
-	arg->alignment : (*ptr)->alignment;
-
-      ptr++;
-    }
-
-  /* Structure size includes tail padding.  This is important for
-     structures that fit in one register on ABIs like the PowerPC64
-     Linux ABI that right justify small structs in a register.
-     It's also needed for nested structure layout, for example
-     struct A { long a; char b; }; struct B { struct A x; char y; };
-     should find y at an offset of 2*sizeof(long) and result in a
-     total size of 3*sizeof(long).  */
-  arg->size = ALIGN (arg->size, arg->alignment);
-
-  if (arg->size == 0)
-    return FFI_BAD_TYPEDEF;
-  else
-    return FFI_OK;
-
-  /*@=usedef@*/
-}
-
-/* Perform machine independent ffi_cif preparation, then call
-   machine dependent routine. */
-
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, 
-			ffi_abi abi, unsigned int nargs, 
-			/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype, 
-			/*@dependent@*/ ffi_type **atypes)
-{
-  unsigned bytes = 0;
-  unsigned int i;
-  ffi_type **ptr;
-
-  FFI_ASSERT(cif != NULL);
-  FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
-
-  cif->abi = abi;
-  cif->arg_types = atypes;
-  cif->nargs = nargs;
-  cif->rtype = rtype;
-
-  cif->flags = 0;
-
-  /* Initialize the return type if necessary */
-  /*@-usedef@*/
-  if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
-    return FFI_BAD_TYPEDEF;
-  /*@=usedef@*/
-
-  /* Perform a sanity check on the return type */
-  FFI_ASSERT_VALID_TYPE(cif->rtype);
-
-  /* x86-64 and s390 stack space allocation is handled in prep_machdep.  */
-#if !defined M68K && !defined __x86_64__ && !defined S390
-  /* Make space for the return structure pointer */
-  if (cif->rtype->type == FFI_TYPE_STRUCT
-      /* MSVC returns small structures in registers.  But we have a different
-      workaround: pretend int32 or int64 return type, and converting to
-      structure afterwards. */
-#ifdef SPARC
-      && (cif->abi != FFI_V9 || cif->rtype->size > 32)
-#endif
-      )
-    bytes = STACK_ARG_SIZE(sizeof(void*));
-#endif
-
-  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
-    {
-
-      /* Initialize any uninitialized aggregate type definitions */
-      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
-	return FFI_BAD_TYPEDEF;
-
-      /* Perform a sanity check on the argument type, do this 
-	 check after the initialization.  */
-      FFI_ASSERT_VALID_TYPE(*ptr);
-
-#if !defined __x86_64__ && !defined S390
-#ifdef SPARC
-      if (((*ptr)->type == FFI_TYPE_STRUCT
-	   && ((*ptr)->size > 16 || cif->abi != FFI_V9))
-	  || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
-	      && cif->abi != FFI_V9))
-	bytes += sizeof(void*);
-      else
-#endif
-	{
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-		/* Don't know if this is a libffi bug or not.  At least on
-		   Windows with MSVC, function call parameters are *not*
-		   aligned in the same way as structure fields are, they are
-		   only aligned in integer boundaries.
-
-		   This doesn't do any harm for cdecl functions and closures,
-		   since the caller cleans up the stack, but it is wrong for
-		   stdcall functions where the callee cleans.
-		*/
-
-	  /* Add any padding if necessary */
-	  if (((*ptr)->alignment - 1) & bytes)
-	    bytes = ALIGN(bytes, (*ptr)->alignment);
-	  
-#endif
-	  bytes += STACK_ARG_SIZE((*ptr)->size);
-	}
-#endif
-    }
-
-  cif->bytes = bytes;
-
-  /* Perform machine dependent cif processing */
-  return ffi_prep_cif_machdep(cif);
-}
diff --git a/lib/wrappers/libffi/msvc/types.c b/lib/wrappers/libffi/msvc/types.c
deleted file mode 100644
index df32190d1..000000000
--- a/lib/wrappers/libffi/msvc/types.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -----------------------------------------------------------------------
-   types.c - Copyright (c) 1996, 1998  Red Hat, Inc.
-   
-   Predefined ffi_types needed by libffi.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-/* Type definitions */
-
-#define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
-#define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
-
-/* Size and alignment are fake here. They must not be 0. */
-FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
-
-FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
-FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
-FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
-FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
-FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
-FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
-FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
-
-#if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
-    || defined IA64
-
-FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
-
-#endif
-
-#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
-
-#elif defined SH
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
-FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
-
-#endif
-
-
-#if defined X86 || defined X86_WIN32 || defined M68K
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
-
-#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
-
-#elif defined SPARC
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-#ifdef SPARC64
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
-#else
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
-#endif
-
-#elif defined X86_64
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
-
-#else
-
-FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
-FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
-
-#endif
-
diff --git a/lib/wrappers/libffi/msvc/win32.c b/lib/wrappers/libffi/msvc/win32.c
deleted file mode 100644
index 2754fd35d..000000000
--- a/lib/wrappers/libffi/msvc/win32.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -----------------------------------------------------------------------
-   win32.S - Copyright (c) 1996, 1998, 2001, 2002  Red Hat, Inc.
-	     Copyright (c) 2001  John Beniton
-	     Copyright (c) 2002  Ranjit Mathew
-			
- 
-   X86 Foreign Function Interface
- 
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
- 
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
- 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-/* theller: almost verbatim translation from gas syntax to MSVC inline
-   assembler code. */
-
-/* theller: ffi_call_x86 now returns an integer - the difference of the stack
-   pointer before and after the function call.  If everything is ok, zero is
-   returned.  If stdcall functions are passed the wrong number of arguments,
-   the difference will be nonzero. */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-__declspec(naked) int
-ffi_call_x86(void (* prepfunc)(char *, extended_cif *), /* 8 */
-	     extended_cif *ecif, /* 12 */
-	     unsigned bytes, /* 16 */
-	     unsigned flags, /* 20 */
-	     unsigned *rvalue, /* 24 */
-	     void (*fn)()) /* 28 */
-{
-	_asm {
-		push ebp
-		mov ebp, esp
-
-		push esi // NEW: this register must be preserved across function calls
-// XXX SAVE ESP NOW!
-		mov esi, esp		// save stack pointer before the call
-
-// Make room for all of the new args.
-		mov ecx, [ebp+16]
-		sub esp, ecx		// sub esp, bytes
-		
-		mov eax, esp
-
-// Place all of the ffi_prep_args in position
-		push [ebp + 12] // ecif
-		push eax
-		call [ebp + 8] // prepfunc
-
-// Return stack to previous state and call the function
-		add esp, 8
-// FIXME: Align the stack to a 128-bit boundary to avoid
-// potential performance hits.
-		call [ebp + 28]
-
-// Load ecif->cif->abi
-		mov ecx, [ebp + 12]
-		mov ecx, [ecx]ecif.cif
-		mov ecx, [ecx]ecif.cif.abi
-		
-		cmp ecx, FFI_STDCALL
-		je noclean
-// STDCALL: Remove the space we pushed for the args
-		mov ecx, [ebp + 16]
-		add esp, ecx
-// CDECL: Caller has already cleaned the stack
-noclean:
-// Check that esp has the same value as before!
-		sub esi, esp
-
-// Load %ecx with the return type code
-		mov ecx, [ebp + 20]
-
-// If the return value pointer is NULL, assume no return value.
-/*
-  Intel asm is weird. We have to explicitly specify 'DWORD PTR' in the nexr instruction,
-  otherwise only one BYTE will be compared (instead of a DWORD)!
- */
-		cmp DWORD PTR [ebp + 24], 0
-		jne sc_retint
-
-// Even if there is no space for the return value, we are
-// obliged to handle floating-point values.
-		cmp ecx, FFI_TYPE_FLOAT
-		jne sc_noretval
-//        fstp  %st(0)
-		fstp st(0)
-
-		jmp sc_epilogue
-
-sc_retint:
-		cmp ecx, FFI_TYPE_INT
-		jne sc_retfloat
-//        # Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp + 24]
-		mov [ecx + 0], eax
-		jmp sc_epilogue
-
-sc_retfloat:
-		cmp ecx, FFI_TYPE_FLOAT
-		jne sc_retdouble
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-//        fstps (%ecx)
-		fstp DWORD PTR [ecx]
-		jmp sc_epilogue
-
-sc_retdouble:
-		cmp ecx, FFI_TYPE_DOUBLE
-		jne sc_retlongdouble
-//        movl  24(%ebp),%ecx
-		mov ecx, [ebp+24]
-		fstp QWORD PTR [ecx]
-		jmp sc_epilogue
-
-		jmp sc_retlongdouble // avoid warning about unused label
-sc_retlongdouble:
-		cmp ecx, FFI_TYPE_LONGDOUBLE
-		jne sc_retint64
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-//        fstpt (%ecx)
-		fstp QWORD PTR [ecx] /* XXX ??? */
-		jmp sc_epilogue
-
-sc_retint64:
-		cmp ecx, FFI_TYPE_SINT64
-		jne sc_retstruct
-// Load %ecx with the pointer to storage for the return value
-		mov ecx, [ebp+24]
-		mov [ecx+0], eax
-		mov [ecx+4], edx
-
-sc_retstruct:
-// Nothing to do!
-
-sc_noretval:
-sc_epilogue:
-		mov eax, esi
-		pop esi // NEW restore: must be preserved across function calls
-		mov esp, ebp
-		pop ebp
-		ret
-	}
-}
diff --git a/lib/wrappers/libffi/msvc/win32_asm.asm b/lib/wrappers/libffi/msvc/win32_asm.asm
deleted file mode 100644
index 407185e6a..000000000
--- a/lib/wrappers/libffi/msvc/win32_asm.asm
+++ /dev/null
@@ -1,470 +0,0 @@
-/* -----------------------------------------------------------------------
-   win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009  Red Hat, Inc.
-	     Copyright (c) 2001  John Beniton
-	     Copyright (c) 2002  Ranjit Mathew
-	     Copyright (c) 2009  Daniel Witte
-			
- 
-   X86 Foreign Function Interface
- 
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
- 
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
- 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-   -----------------------------------------------------------------------
-   */
- 
-#define LIBFFI_ASM
-#include <fficonfig.h>
-#include <ffi.h>
-
-.386
-.MODEL FLAT, C
-
-EXTRN ffi_closure_SYSV_inner:NEAR
-
-_TEXT SEGMENT
-
-ffi_call_win32 PROC NEAR,
-    ffi_prep_args : NEAR PTR DWORD,
-    ecif          : NEAR PTR DWORD,
-    cif_abi       : DWORD,
-    cif_bytes     : DWORD,
-    cif_flags     : DWORD,
-    rvalue        : NEAR PTR DWORD,
-    fn            : NEAR PTR DWORD
-
-        ;; Make room for all of the new args.
-        mov  ecx, cif_bytes
-        sub  esp, ecx
-
-        mov  eax, esp
-
-        ;; Place all of the ffi_prep_args in position
-        push ecif
-        push eax
-        call ffi_prep_args
-
-        ;; Return stack to previous state and call the function
-        add  esp, 8
-
-	;; Handle thiscall and fastcall
-	cmp cif_abi, 3 ;; FFI_THISCALL
-	jz do_thiscall
-	cmp cif_abi, 4 ;; FFI_FASTCALL
-	jnz do_stdcall
-	mov ecx, DWORD PTR [esp]
-	mov edx, DWORD PTR [esp+4]
-	add esp, 8
-	jmp do_stdcall
-do_thiscall:
-	mov ecx, DWORD PTR [esp]
-	add esp, 4
-do_stdcall:
-        call fn
-
-        ;; cdecl:   we restore esp in the epilogue, so there's no need to
-        ;;          remove the space we pushed for the args.
-        ;; stdcall: the callee has already cleaned the stack.
-
-        ;; Load ecx with the return type code
-        mov  ecx, cif_flags
-
-        ;; If the return value pointer is NULL, assume no return value.
-        cmp  rvalue, 0
-        jne  ca_jumptable
-
-        ;; Even if there is no space for the return value, we are
-        ;; obliged to handle floating-point values.
-        cmp  ecx, FFI_TYPE_FLOAT
-        jne  ca_epilogue
-        fstp st(0)
-
-        jmp  ca_epilogue
-
-ca_jumptable:
-        jmp  [ca_jumpdata + 4 * ecx]
-ca_jumpdata:
-        ;; Do not insert anything here between label and jump table.
-        dd offset ca_epilogue       ;; FFI_TYPE_VOID
-        dd offset ca_retint         ;; FFI_TYPE_INT
-        dd offset ca_retfloat       ;; FFI_TYPE_FLOAT
-        dd offset ca_retdouble      ;; FFI_TYPE_DOUBLE
-        dd offset ca_retlongdouble  ;; FFI_TYPE_LONGDOUBLE
-        dd offset ca_retuint8       ;; FFI_TYPE_UINT8
-        dd offset ca_retsint8       ;; FFI_TYPE_SINT8
-        dd offset ca_retuint16      ;; FFI_TYPE_UINT16
-        dd offset ca_retsint16      ;; FFI_TYPE_SINT16
-        dd offset ca_retint         ;; FFI_TYPE_UINT32
-        dd offset ca_retint         ;; FFI_TYPE_SINT32
-        dd offset ca_retint64       ;; FFI_TYPE_UINT64
-        dd offset ca_retint64       ;; FFI_TYPE_SINT64
-        dd offset ca_epilogue       ;; FFI_TYPE_STRUCT
-        dd offset ca_retint         ;; FFI_TYPE_POINTER
-        dd offset ca_retstruct1b    ;; FFI_TYPE_SMALL_STRUCT_1B
-        dd offset ca_retstruct2b    ;; FFI_TYPE_SMALL_STRUCT_2B
-        dd offset ca_retint         ;; FFI_TYPE_SMALL_STRUCT_4B
-        dd offset ca_epilogue       ;; FFI_TYPE_MS_STRUCT
-
-        /* Sign/zero extend as appropriate.  */
-ca_retuint8:
-        movzx eax, al
-        jmp   ca_retint
-
-ca_retsint8:
-        movsx eax, al
-        jmp   ca_retint
-
-ca_retuint16:
-        movzx eax, ax
-        jmp   ca_retint
-
-ca_retsint16:
-        movsx eax, ax
-        jmp   ca_retint
-
-ca_retint:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        mov   [ecx + 0], eax
-        jmp   ca_epilogue
-
-ca_retint64:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        mov   [ecx + 0], eax
-        mov   [ecx + 4], edx
-        jmp   ca_epilogue
-
-ca_retfloat:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        fstp  DWORD PTR [ecx]
-        jmp   ca_epilogue
-
-ca_retdouble:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        fstp  QWORD PTR [ecx]
-        jmp   ca_epilogue
-
-ca_retlongdouble:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        fstp  TBYTE PTR [ecx]
-        jmp   ca_epilogue
-
-ca_retstruct1b:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        mov   [ecx + 0], al
-        jmp   ca_epilogue
-
-ca_retstruct2b:
-        ;; Load %ecx with the pointer to storage for the return value
-        mov   ecx, rvalue
-        mov   [ecx + 0], ax
-        jmp   ca_epilogue
-
-ca_epilogue:
-        ;; Epilogue code is autogenerated.
-        ret
-ffi_call_win32 ENDP
-
-ffi_closure_THISCALL PROC NEAR FORCEFRAME
-	sub	esp, 40
-	lea	edx, [ebp -24]
-	mov	[ebp - 12], edx	/* resp */
-	lea	edx, [ebp + 12]  /* account for stub return address on stack */
-	jmp	stub
-ffi_closure_THISCALL ENDP
-
-ffi_closure_SYSV PROC NEAR FORCEFRAME
-    ;; the ffi_closure ctx is passed in eax by the trampoline.
-
-        sub  esp, 40
-        lea  edx, [ebp - 24]
-        mov  [ebp - 12], edx         ;; resp
-        lea  edx, [ebp + 8]
-stub::
-        mov  [esp + 8], edx          ;; args
-        lea  edx, [ebp - 12]
-        mov  [esp + 4], edx          ;; &resp
-        mov  [esp], eax              ;; closure
-        call ffi_closure_SYSV_inner
-        mov  ecx, [ebp - 12]
-
-cs_jumptable:
-        jmp  [cs_jumpdata + 4 * eax]
-cs_jumpdata:
-        ;; Do not insert anything here between the label and jump table.
-        dd offset cs_epilogue       ;; FFI_TYPE_VOID
-        dd offset cs_retint         ;; FFI_TYPE_INT
-        dd offset cs_retfloat       ;; FFI_TYPE_FLOAT
-        dd offset cs_retdouble      ;; FFI_TYPE_DOUBLE
-        dd offset cs_retlongdouble  ;; FFI_TYPE_LONGDOUBLE
-        dd offset cs_retuint8       ;; FFI_TYPE_UINT8
-        dd offset cs_retsint8       ;; FFI_TYPE_SINT8
-        dd offset cs_retuint16      ;; FFI_TYPE_UINT16
-        dd offset cs_retsint16      ;; FFI_TYPE_SINT16
-        dd offset cs_retint         ;; FFI_TYPE_UINT32
-        dd offset cs_retint         ;; FFI_TYPE_SINT32
-        dd offset cs_retint64       ;; FFI_TYPE_UINT64
-        dd offset cs_retint64       ;; FFI_TYPE_SINT64
-        dd offset cs_retstruct      ;; FFI_TYPE_STRUCT
-        dd offset cs_retint         ;; FFI_TYPE_POINTER
-        dd offset cs_retsint8       ;; FFI_TYPE_SMALL_STRUCT_1B
-        dd offset cs_retsint16      ;; FFI_TYPE_SMALL_STRUCT_2B
-        dd offset cs_retint         ;; FFI_TYPE_SMALL_STRUCT_4B
-        dd offset cs_retmsstruct    ;; FFI_TYPE_MS_STRUCT
-
-cs_retuint8:
-        movzx eax, BYTE PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retsint8:
-        movsx eax, BYTE PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retuint16:
-        movzx eax, WORD PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retsint16:
-        movsx eax, WORD PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retint:
-        mov   eax, [ecx]
-        jmp   cs_epilogue
-
-cs_retint64:
-        mov   eax, [ecx + 0]
-        mov   edx, [ecx + 4]
-        jmp   cs_epilogue
-
-cs_retfloat:
-        fld   DWORD PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retdouble:
-        fld   QWORD PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retlongdouble:
-        fld   TBYTE PTR [ecx]
-        jmp   cs_epilogue
-
-cs_retstruct:
-        ;; Caller expects us to pop struct return value pointer hidden arg.
-        ;; Epilogue code is autogenerated.
-        ret	4
-
-cs_retmsstruct:
-        ;; Caller expects us to return a pointer to the real return value.
-        mov   eax, ecx
-        ;; Caller doesn't expects us to pop struct return value pointer hidden arg.
-        jmp   cs_epilogue
-
-cs_epilogue:
-        ;; Epilogue code is autogenerated.
-        ret
-ffi_closure_SYSV ENDP
-
-#if !FFI_NO_RAW_API
-
-#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
-#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
-#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
-#define CIF_FLAGS_OFFSET 20
-
-ffi_closure_raw_THISCALL PROC NEAR USES esi FORCEFRAME
-	sub esp, 36
-	mov  esi, [eax + RAW_CLOSURE_CIF_OFFSET]        ;; closure->cif
-	mov  edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET]  ;; closure->user_data
-	mov [esp + 12], edx
-	lea edx, [ebp + 12]
-	jmp stubraw
-ffi_closure_raw_THISCALL ENDP
-
-ffi_closure_raw_SYSV PROC NEAR USES esi FORCEFRAME
-    ;; the ffi_closure ctx is passed in eax by the trampoline.
-
-        sub  esp, 40
-        mov  esi, [eax + RAW_CLOSURE_CIF_OFFSET]        ;; closure->cif
-        mov  edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET]  ;; closure->user_data
-        mov  [esp + 12], edx                            ;; user_data
-        lea  edx, [ebp + 8]
-stubraw::
-        mov  [esp + 8], edx                             ;; raw_args
-        lea  edx, [ebp - 24]
-        mov  [esp + 4], edx                             ;; &res
-        mov  [esp], esi                                 ;; cif
-        call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET]   ;; closure->fun
-        mov  eax, [esi + CIF_FLAGS_OFFSET]              ;; cif->flags
-        lea  ecx, [ebp - 24]
-
-cr_jumptable:
-        jmp  [cr_jumpdata + 4 * eax]
-cr_jumpdata:
-        ;; Do not insert anything here between the label and jump table.
-        dd offset cr_epilogue       ;; FFI_TYPE_VOID
-        dd offset cr_retint         ;; FFI_TYPE_INT
-        dd offset cr_retfloat       ;; FFI_TYPE_FLOAT
-        dd offset cr_retdouble      ;; FFI_TYPE_DOUBLE
-        dd offset cr_retlongdouble  ;; FFI_TYPE_LONGDOUBLE
-        dd offset cr_retuint8       ;; FFI_TYPE_UINT8
-        dd offset cr_retsint8       ;; FFI_TYPE_SINT8
-        dd offset cr_retuint16      ;; FFI_TYPE_UINT16
-        dd offset cr_retsint16      ;; FFI_TYPE_SINT16
-        dd offset cr_retint         ;; FFI_TYPE_UINT32
-        dd offset cr_retint         ;; FFI_TYPE_SINT32
-        dd offset cr_retint64       ;; FFI_TYPE_UINT64
-        dd offset cr_retint64       ;; FFI_TYPE_SINT64
-        dd offset cr_epilogue       ;; FFI_TYPE_STRUCT
-        dd offset cr_retint         ;; FFI_TYPE_POINTER
-        dd offset cr_retsint8       ;; FFI_TYPE_SMALL_STRUCT_1B
-        dd offset cr_retsint16      ;; FFI_TYPE_SMALL_STRUCT_2B
-        dd offset cr_retint         ;; FFI_TYPE_SMALL_STRUCT_4B
-        dd offset cr_epilogue       ;; FFI_TYPE_MS_STRUCT
-
-cr_retuint8:
-        movzx eax, BYTE PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retsint8:
-        movsx eax, BYTE PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retuint16:
-        movzx eax, WORD PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retsint16:
-        movsx eax, WORD PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retint:
-        mov   eax, [ecx]
-        jmp   cr_epilogue
-
-cr_retint64:
-        mov   eax, [ecx + 0]
-        mov   edx, [ecx + 4]
-        jmp   cr_epilogue
-
-cr_retfloat:
-        fld   DWORD PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retdouble:
-        fld   QWORD PTR [ecx]
-        jmp   cr_epilogue
-
-cr_retlongdouble:
-        fld   TBYTE PTR [ecx]
-        jmp   cr_epilogue
-
-cr_epilogue:
-        ;; Epilogue code is autogenerated.
-        ret
-ffi_closure_raw_SYSV ENDP
-
-#endif /* !FFI_NO_RAW_API */
-
-ffi_closure_STDCALL PROC NEAR FORCEFRAME
-    ;; the ffi_closure ctx is passed in eax by the trampoline.
-
-        sub  esp, 40
-        lea  edx, [ebp - 24]
-        mov  [ebp - 12], edx         ;; resp
-        lea  edx, [ebp + 12]         ;; account for stub return address on stack
-        mov  [esp + 8], edx          ;; args
-        lea  edx, [ebp - 12]
-        mov  [esp + 4], edx          ;; &resp
-        mov  [esp], eax              ;; closure
-        call ffi_closure_SYSV_inner
-        mov  ecx, [ebp - 12]
-
-cd_jumptable:
-        jmp  [cd_jumpdata + 4 * eax]
-cd_jumpdata:
-        ;; Do not insert anything here between the label and jump table.
-        dd offset cd_epilogue       ;; FFI_TYPE_VOID
-        dd offset cd_retint         ;; FFI_TYPE_INT
-        dd offset cd_retfloat       ;; FFI_TYPE_FLOAT
-        dd offset cd_retdouble      ;; FFI_TYPE_DOUBLE
-        dd offset cd_retlongdouble  ;; FFI_TYPE_LONGDOUBLE
-        dd offset cd_retuint8       ;; FFI_TYPE_UINT8
-        dd offset cd_retsint8       ;; FFI_TYPE_SINT8
-        dd offset cd_retuint16      ;; FFI_TYPE_UINT16
-        dd offset cd_retsint16      ;; FFI_TYPE_SINT16
-        dd offset cd_retint         ;; FFI_TYPE_UINT32
-        dd offset cd_retint         ;; FFI_TYPE_SINT32
-        dd offset cd_retint64       ;; FFI_TYPE_UINT64
-        dd offset cd_retint64       ;; FFI_TYPE_SINT64
-        dd offset cd_epilogue       ;; FFI_TYPE_STRUCT
-        dd offset cd_retint         ;; FFI_TYPE_POINTER
-        dd offset cd_retsint8       ;; FFI_TYPE_SMALL_STRUCT_1B
-        dd offset cd_retsint16      ;; FFI_TYPE_SMALL_STRUCT_2B
-        dd offset cd_retint         ;; FFI_TYPE_SMALL_STRUCT_4B
-
-cd_retuint8:
-        movzx eax, BYTE PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retsint8:
-        movsx eax, BYTE PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retuint16:
-        movzx eax, WORD PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retsint16:
-        movsx eax, WORD PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retint:
-        mov   eax, [ecx]
-        jmp   cd_epilogue
-
-cd_retint64:
-        mov   eax, [ecx + 0]
-        mov   edx, [ecx + 4]
-        jmp   cd_epilogue
-
-cd_retfloat:
-        fld   DWORD PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retdouble:
-        fld   QWORD PTR [ecx]
-        jmp   cd_epilogue
-
-cd_retlongdouble:
-        fld   TBYTE PTR [ecx]
-        jmp   cd_epilogue
-
-cd_epilogue:
-        ;; Epilogue code is autogenerated.
-        ret
-ffi_closure_STDCALL ENDP
-
-_TEXT ENDS
-END
diff --git a/lib/wrappers/libffi/msvc/win64_asm.asm b/lib/wrappers/libffi/msvc/win64_asm.asm
deleted file mode 100644
index 301188bc9..000000000
--- a/lib/wrappers/libffi/msvc/win64_asm.asm
+++ /dev/null
@@ -1,156 +0,0 @@
-PUBLIC	ffi_call_AMD64
-
-EXTRN	__chkstk:NEAR
-EXTRN	ffi_closure_SYSV:NEAR
-
-_TEXT	SEGMENT
-
-;;; ffi_closure_OUTER will be called with these registers set:
-;;;    rax points to 'closure'
-;;;    r11 contains a bit mask that specifies which of the
-;;;    first four parameters are float or double
-;;;
-;;; It must move the parameters passed in registers to their stack location,
-;;; call ffi_closure_SYSV for the actual work, then return the result.
-;;; 
-ffi_closure_OUTER PROC FRAME
-	;; save actual arguments to their stack space.
-	test	r11, 1
-	jne	first_is_float	
-	mov	QWORD PTR [rsp+8], rcx
-	jmp	second
-first_is_float:
-	movlpd	QWORD PTR [rsp+8], xmm0
-
-second:
-	test	r11, 2
-	jne	second_is_float	
-	mov	QWORD PTR [rsp+16], rdx
-	jmp	third
-second_is_float:
-	movlpd	QWORD PTR [rsp+16], xmm1
-
-third:
-	test	r11, 4
-	jne	third_is_float	
-	mov	QWORD PTR [rsp+24], r8
-	jmp	forth
-third_is_float:
-	movlpd	QWORD PTR [rsp+24], xmm2
-
-forth:
-	test	r11, 8
-	jne	forth_is_float	
-	mov	QWORD PTR [rsp+32], r9
-	jmp	done
-forth_is_float:
-	movlpd	QWORD PTR [rsp+32], xmm3
-
-done:
-.ALLOCSTACK 40
-	sub	rsp, 40
-.ENDPROLOG
-	mov	rcx, rax	; context is first parameter
-	mov	rdx, rsp	; stack is second parameter
-	add	rdx, 40		; correct our own area
-	mov	rax, ffi_closure_SYSV
-	call	rax		; call the real closure function
-	;; Here, code is missing that handles float return values
-	add	rsp, 40
-	movd	xmm0, rax	; In case the closure returned a float.
-	ret	0
-ffi_closure_OUTER ENDP
-
-
-;;; ffi_call_AMD64
-
-stack$ = 0
-prepfunc$ = 32
-ecif$ = 40
-bytes$ = 48
-flags$ = 56
-rvalue$ = 64
-fn$ = 72
-
-ffi_call_AMD64 PROC FRAME
-
-	mov	QWORD PTR [rsp+32], r9
-	mov	QWORD PTR [rsp+24], r8
-	mov	QWORD PTR [rsp+16], rdx
-	mov	QWORD PTR [rsp+8], rcx
-.PUSHREG rbp
-	push	rbp
-.ALLOCSTACK 48
-	sub	rsp, 48					; 00000030H
-.SETFRAME rbp, 32
-	lea	rbp, QWORD PTR [rsp+32]
-.ENDPROLOG
-
-	mov	eax, DWORD PTR bytes$[rbp]
-	add	rax, 15
-	and	rax, -16
-	call	__chkstk
-	sub	rsp, rax
-	lea	rax, QWORD PTR [rsp+32]
-	mov	QWORD PTR stack$[rbp], rax
-
-	mov	rdx, QWORD PTR ecif$[rbp]
-	mov	rcx, QWORD PTR stack$[rbp]
-	call	QWORD PTR prepfunc$[rbp]
-
-	mov	rsp, QWORD PTR stack$[rbp]
-
-	movlpd	xmm3, QWORD PTR [rsp+24]
-	movd	r9, xmm3
-
-	movlpd	xmm2, QWORD PTR [rsp+16]
-	movd	r8, xmm2
-
-	movlpd	xmm1, QWORD PTR [rsp+8]
-	movd	rdx, xmm1
-
-	movlpd	xmm0, QWORD PTR [rsp]
-	movd	rcx, xmm0
-
-	call	QWORD PTR fn$[rbp]
-ret_int$:
- 	cmp	DWORD PTR flags$[rbp], 1 ; FFI_TYPE_INT
- 	jne	ret_float$
-
-	mov	rcx, QWORD PTR rvalue$[rbp]
-	mov	DWORD PTR [rcx], eax
-	jmp	SHORT ret_nothing$
-
-ret_float$:
- 	cmp	DWORD PTR flags$[rbp], 2 ; FFI_TYPE_FLOAT
- 	jne	SHORT ret_double$
-
- 	mov	rax, QWORD PTR rvalue$[rbp]
- 	movlpd	QWORD PTR [rax], xmm0
- 	jmp	SHORT ret_nothing$
-
-ret_double$:
- 	cmp	DWORD PTR flags$[rbp], 3 ; FFI_TYPE_DOUBLE
- 	jne	SHORT ret_int64$
-
- 	mov	rax, QWORD PTR rvalue$[rbp]
- 	movlpd	QWORD PTR [rax], xmm0
- 	jmp	SHORT ret_nothing$
-
-ret_int64$:
-  	cmp	DWORD PTR flags$[rbp], 12 ; FFI_TYPE_SINT64
-  	jne	ret_nothing$
-
- 	mov	rcx, QWORD PTR rvalue$[rbp]
- 	mov	QWORD PTR [rcx], rax
- 	jmp	SHORT ret_nothing$
-	
-ret_nothing$:
-	xor	eax, eax
-
-	lea	rsp, QWORD PTR [rbp+16]
-	pop	rbp
-	ret	0
-ffi_call_AMD64 ENDP
-_TEXT	ENDS
-END
diff --git a/lib/wrappers/libuv.nim b/lib/wrappers/libuv.nim
index 0cb14fb2b..3e28815ad 100644
--- a/lib/wrappers/libuv.nim
+++ b/lib/wrappers/libuv.nim
@@ -1,3 +1,12 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
 ## libuv is still fast moving target
 ## This file was last updated against a development HEAD revision of https://github.com/joyent/libuv/
 
@@ -136,7 +145,7 @@ type
     fs_event_init* {.importc: "fs_event_init".}: uint64
 
   Loop* {.pure, final, importc: "uv_loop_t", header: "uv.h".} = object
-    # ares_handles_* {.importc: "uv_ares_handles_".}: pointer # XXX: This seems to be a private field? 
+    # ares_handles_* {.importc: "uv_ares_handles_".}: pointer # XXX: This seems to be a private field?
     eio_want_poll_notifier* {.importc: "uv_eio_want_poll_notifier".}: TAsync
     eio_done_poll_notifier* {.importc: "uv_eio_done_poll_notifier".}: TAsync
     eio_poller* {.importc: "uv_eio_poller".}: TIdle
diff --git a/lib/wrappers/odbcsql.nim b/lib/wrappers/odbcsql.nim
index 22297497c..971861a6a 100644
--- a/lib/wrappers/odbcsql.nim
+++ b/lib/wrappers/odbcsql.nim
@@ -1,3 +1,11 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
 
 {.deadCodeElim: on.}
 
@@ -27,7 +35,7 @@ else:
 #   ftMemo      SQL_BINARY // SQL_VARCHAR
 #
 
-type 
+type
   TSqlChar* = char
   TSqlSmallInt* = int16
   SqlUSmallInt* = int16
@@ -64,7 +72,7 @@ type
     # TSqlFloat: TSqlFloat, # Name conflict if we drop `T`
     TSqlHWND: SqlHWND].}
 
-const                         # SQL data type codes 
+const                         # SQL data type codes
   SQL_UNKNOWN_TYPE* = 0
   SQL_LONGVARCHAR* = (- 1)
   SQL_BINARY* = (- 2)
@@ -95,8 +103,8 @@ const                         # SQL data type codes
   SQL_INTERVAL* = 10
   SQL_GUID* = - 11            # interval codes
 
-when ODBCVER >= 0x0300: 
-  const 
+when ODBCVER >= 0x0300:
+  const
     SQL_CODE_YEAR* = 1
     SQL_CODE_MONTH* = 2
     SQL_CODE_DAY* = 3
@@ -123,8 +131,8 @@ when ODBCVER >= 0x0300:
     SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
     SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
     SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
-else: 
-  const 
+else:
+  const
     SQL_INTERVAL_YEAR* = - 80
     SQL_INTERVAL_MONTH* = - 81
     SQL_INTERVAL_YEAR_TO_MONTH* = - 82
@@ -140,20 +148,20 @@ else:
     SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
 
 
-when ODBCVER < 0x0300: 
-  const 
+when ODBCVER < 0x0300:
+  const
     SQL_UNICODE* = - 95
     SQL_UNICODE_VARCHAR* = - 96
     SQL_UNICODE_LONGVARCHAR* = - 97
     SQL_UNICODE_CHAR* = SQL_UNICODE
-else: 
-  # The previous definitions for SQL_UNICODE_ are historical and obsolete 
-  const 
+else:
+  # The previous definitions for SQL_UNICODE_ are historical and obsolete
+  const
     SQL_UNICODE* = SQL_WCHAR
     SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
     SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
     SQL_UNICODE_CHAR* = SQL_WCHAR
-const                         # C datatype to SQL datatype mapping 
+const                         # C datatype to SQL datatype mapping
   SQL_C_CHAR* = SQL_CHAR
   SQL_C_LONG* = SQL_INTEGER
   SQL_C_SHORT* = SQL_SMALLINT
@@ -197,30 +205,30 @@ const                         # C datatype to SQL datatype mapping
   SQL_C_GUID* = SQL_GUID
   SQL_TYPE_NULL* = 0
 
-when ODBCVER < 0x0300: 
-  const 
+when ODBCVER < 0x0300:
+  const
     SQL_TYPE_MIN* = SQL_BIT
     SQL_TYPE_MAX* = SQL_VARCHAR
 
-const 
+const
   SQL_C_VARBOOKMARK* = SQL_C_BINARY
   SQL_API_SQLDESCRIBEPARAM* = 58
   SQL_NO_TOTAL* = - 4
 
-type 
-  SQL_DATE_STRUCT* {.final, pure.} = object 
+type
+  SQL_DATE_STRUCT* {.final, pure.} = object
     Year*: TSqlSmallInt
     Month*: SqlUSmallInt
     Day*: SqlUSmallInt
 
   PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
-  SQL_TIME_STRUCT* {.final, pure.} = object 
+  SQL_TIME_STRUCT* {.final, pure.} = object
     Hour*: SqlUSmallInt
     Minute*: SqlUSmallInt
     Second*: SqlUSmallInt
 
   PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
-  SQL_TIMESTAMP_STRUCT* {.final, pure.} = object 
+  SQL_TIMESTAMP_STRUCT* {.final, pure.} = object
     Year*: SqlUSmallInt
     Month*: SqlUSmallInt
     Day*: SqlUSmallInt
@@ -231,34 +239,34 @@ type
 
   PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
 
-const 
+const
   SQL_NAME_LEN* = 128
   SQL_OV_ODBC3* = 3
   SQL_OV_ODBC2* = 2
-  SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect 
+  SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect
   SQL_DRIVER_NOPROMPT* = 0
   SQL_DRIVER_COMPLETE* = 1
   SQL_DRIVER_PROMPT* = 2
-  SQL_DRIVER_COMPLETE_REQUIRED* = 3 
-  SQL_IS_POINTER* = (- 4)  # whether an attribute is a pointer or not 
+  SQL_DRIVER_COMPLETE_REQUIRED* = 3
+  SQL_IS_POINTER* = (- 4)  # whether an attribute is a pointer or not
   SQL_IS_UINTEGER* = (- 5)
   SQL_IS_INTEGER* = (- 6)
   SQL_IS_USMALLINT* = (- 7)
-  SQL_IS_SMALLINT* = (- 8)    # SQLExtendedFetch "fFetchType" values 
+  SQL_IS_SMALLINT* = (- 8)    # SQLExtendedFetch "fFetchType" values
   SQL_FETCH_BOOKMARK* = 8
-  SQL_SCROLL_OPTIONS* = 44    # SQL_USE_BOOKMARKS options 
+  SQL_SCROLL_OPTIONS* = 44    # SQL_USE_BOOKMARKS options
   SQL_UB_OFF* = 0
   SQL_UB_ON* = 1
   SQL_UB_DEFAULT* = SQL_UB_OFF
   SQL_UB_FIXED* = SQL_UB_ON
-  SQL_UB_VARIABLE* = 2        # SQL_SCROLL_OPTIONS masks 
+  SQL_UB_VARIABLE* = 2        # SQL_SCROLL_OPTIONS masks
   SQL_SO_FORWARD_ONLY* = 0x00000001
   SQL_SO_KEYSET_DRIVEN* = 0x00000002
   SQL_SO_DYNAMIC* = 0x00000004
   SQL_SO_MIXED* = 0x00000008
   SQL_SO_STATIC* = 0x00000010
   SQL_BOOKMARK_PERSISTENCE* = 82
-  SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values 
+  SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values
   SQL_BP_CLOSE* = 0x00000001
   SQL_BP_DELETE* = 0x00000002
   SQL_BP_DROP* = 0x00000004
@@ -275,32 +283,32 @@ const
   SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
   SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
   SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
-  SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's 
+  SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's
   SQL_CA1_NEXT* = 1
   SQL_CA1_ABSOLUTE* = 2
   SQL_CA1_RELATIVE* = 4
-  SQL_CA1_BOOKMARK* = 8       # supported SQLSetPos LockType's 
+  SQL_CA1_BOOKMARK* = 8       # supported SQLSetPos LockType's
   SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
   SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
-  SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations 
+  SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations
   SQL_CA1_POS_POSITION* = 0x00000200
   SQL_CA1_POS_UPDATE* = 0x00000400
   SQL_CA1_POS_DELETE* = 0x00000800
-  SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes 
+  SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes
   SQL_CA1_POSITIONED_UPDATE* = 0x00002000
   SQL_CA1_POSITIONED_DELETE* = 0x00004000
-  SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations 
+  SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations
   SQL_CA1_BULK_ADD* = 0x00010000
   SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
   SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
-  SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY 
+  SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY
   SQL_CA2_READ_ONLY_CONCURRENCY* = 1
   SQL_CA2_LOCK_CONCURRENCY* = 2
   SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
-  SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates 
+  SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates
   SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
   SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
-  SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 #  semantics of SQL_ATTR_MAX_ROWS 
+  SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 #  semantics of SQL_ATTR_MAX_ROWS
   SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
   SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
   SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
@@ -308,25 +316,25 @@ const
   SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
   SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
       SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
-      SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of 
-                                                           # SQL_DIAG_CURSOR_ROW_COUNT 
+      SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of
+                                                           # SQL_DIAG_CURSOR_ROW_COUNT
   SQL_CA2_CRC_EXACT* = 0x00001000
-  SQL_CA2_CRC_APPROXIMATE* = 0x00002000 #  the kinds of positioned statements that can be simulated 
+  SQL_CA2_CRC_APPROXIMATE* = 0x00002000 #  the kinds of positioned statements that can be simulated
   SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
   SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
-  SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 #  Operations in SQLBulkOperations 
+  SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 #  Operations in SQLBulkOperations
   SQL_ADD* = 4
   SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
   SQL_UPDATE_BY_BOOKMARK* = 5
   SQL_DELETE_BY_BOOKMARK* = 6
-  SQL_FETCH_BY_BOOKMARK* = 7  # Operations in SQLSetPos 
+  SQL_FETCH_BY_BOOKMARK* = 7  # Operations in SQLSetPos
   SQL_POSITION* = 0
   SQL_REFRESH* = 1
   SQL_UPDATE* = 2
-  SQL_DELETE* = 3             # Lock options in SQLSetPos 
+  SQL_DELETE* = 3             # Lock options in SQLSetPos
   SQL_LOCK_NO_CHANGE* = 0
   SQL_LOCK_EXCLUSIVE* = 1
-  SQL_LOCK_UNLOCK* = 2        # SQLExtendedFetch "rgfRowStatus" element values 
+  SQL_LOCK_UNLOCK* = 2        # SQLExtendedFetch "rgfRowStatus" element values
   SQL_ROW_SUCCESS* = 0
   SQL_ROW_DELETED* = 1
   SQL_ROW_UPDATED* = 2
@@ -336,10 +344,10 @@ const
   SQL_ROW_SUCCESS_WITH_INFO* = 6
   SQL_ROW_PROCEED* = 0
   SQL_ROW_IGNORE* = 1
-  SQL_MAX_DSN_LENGTH* = 32    # maximum data source name size 
+  SQL_MAX_DSN_LENGTH* = 32    # maximum data source name size
   SQL_MAX_OPTION_STRING_LENGTH* = 256
   SQL_ODBC_CURSORS* = 110
-  SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options 
+  SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options
   SQL_CUR_USE_IF_NEEDED* = 0
   SQL_CUR_USE_ODBC* = 1
   SQL_CUR_USE_DRIVER* = 2
@@ -349,7 +357,7 @@ const
   SQL_PARAM_INPUT_OUTPUT* = 2
   SQL_RESULT_COL* = 3
   SQL_PARAM_OUTPUT* = 4
-  SQL_RETURN_VALUE* = 5       # special length/indicator values 
+  SQL_RETURN_VALUE* = 5       # special length/indicator values
   SQL_NULL_DATA* = (- 1)
   SQL_DATA_AT_EXEC* = (- 2)
   SQL_SUCCESS* = 0
@@ -358,20 +366,20 @@ const
   SQL_ERROR* = (- 1)
   SQL_INVALID_HANDLE* = (- 2)
   SQL_STILL_EXECUTING* = 2
-  SQL_NEED_DATA* = 99         # flags for null-terminated string 
-  SQL_NTS* = (- 3)            # maximum message length 
-  SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants 
+  SQL_NEED_DATA* = 99         # flags for null-terminated string
+  SQL_NTS* = (- 3)            # maximum message length
+  SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants
   SQL_DATE_LEN* = 10
-  SQL_TIME_LEN* = 8           # add P+1 if precision is nonzero 
-  SQL_TIMESTAMP_LEN* = 19     # add P+1 if precision is nonzero 
-                              # handle type identifiers 
+  SQL_TIME_LEN* = 8           # add P+1 if precision is nonzero
+  SQL_TIMESTAMP_LEN* = 19     # add P+1 if precision is nonzero
+                              # handle type identifiers
   SQL_HANDLE_ENV* = 1
   SQL_HANDLE_DBC* = 2
   SQL_HANDLE_STMT* = 3
-  SQL_HANDLE_DESC* = 4        # environment attribute 
-  SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes 
+  SQL_HANDLE_DESC* = 4        # environment attribute
+  SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes
   SQL_ATTR_AUTO_IPD* = 10001
-  SQL_ATTR_METADATA_ID* = 10014 # statement attributes 
+  SQL_ATTR_METADATA_ID* = 10014 # statement attributes
   SQL_ATTR_APP_ROW_DESC* = 10010
   SQL_ATTR_APP_PARAM_DESC* = 10011
   SQL_ATTR_IMP_ROW_DESC* = 10012
@@ -434,21 +442,21 @@ const
   SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
   SQL_AUTOCOMMIT_OFF* = 0
   SQL_AUTOCOMMIT_ON* = 1
-  SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values 
+  SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values
   SQL_NONSCROLLABLE* = 0
-  SQL_SCROLLABLE* = 1         # SQL_CURSOR_TYPE options 
+  SQL_SCROLLABLE* = 1         # SQL_CURSOR_TYPE options
   SQL_CURSOR_FORWARD_ONLY* = 0
   SQL_CURSOR_KEYSET_DRIVEN* = 1
   SQL_CURSOR_DYNAMIC* = 2
   SQL_CURSOR_STATIC* = 3
-  SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value 
-                                                     # SQL_CONCURRENCY options 
+  SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value
+                                                     # SQL_CONCURRENCY options
   SQL_CONCUR_READ_ONLY* = 1
   SQL_CONCUR_LOCK* = 2
   SQL_CONCUR_ROWVER* = 3
   SQL_CONCUR_VALUES* = 4
-  SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value 
-                                             # identifiers of fields in the SQL descriptor 
+  SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value
+                                             # identifiers of fields in the SQL descriptor
   SQL_DESC_COUNT* = 1001
   SQL_DESC_TYPE* = 1002
   SQL_DESC_LENGTH* = 1003
@@ -462,7 +470,7 @@ const
   SQL_DESC_NAME* = 1011
   SQL_DESC_UNNAMED* = 1012
   SQL_DESC_OCTET_LENGTH* = 1013
-  SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area 
+  SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area
   SQL_DIAG_RETURNCODE* = 1
   SQL_DIAG_NUMBER* = 2
   SQL_DIAG_ROW_COUNT* = 3
@@ -474,7 +482,7 @@ const
   SQL_DIAG_SUBCLASS_ORIGIN* = 9
   SQL_DIAG_CONNECTION_NAME* = 10
   SQL_DIAG_SERVER_NAME* = 11
-  SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes 
+  SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes
   SQL_DIAG_ALTER_TABLE* = 4
   SQL_DIAG_CREATE_INDEX* = (- 1)
   SQL_DIAG_CREATE_TABLE* = 77
@@ -490,36 +498,36 @@ const
   SQL_DIAG_REVOKE* = 59
   SQL_DIAG_SELECT_CURSOR* = 85
   SQL_DIAG_UNKNOWN_STATEMENT* = 0
-  SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity 
+  SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity
   SQL_UNSPECIFIED* = 0
   SQL_INSENSITIVE* = 1
-  SQL_SENSITIVE* = 2          # GetTypeInfo() request for all data types 
-  SQL_ALL_TYPES* = 0          # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() 
+  SQL_SENSITIVE* = 2          # GetTypeInfo() request for all data types
+  SQL_ALL_TYPES* = 0          # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
   SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
-                    #    specifies the data type 
-  SQL_ARD_TYPE* = (- 99)      # SQL date/time type subcodes 
+                    #    specifies the data type
+  SQL_ARD_TYPE* = (- 99)      # SQL date/time type subcodes
   SQL_CODE_DATE* = 1
   SQL_CODE_TIME* = 2
-  SQL_CODE_TIMESTAMP* = 3     # CLI option values 
+  SQL_CODE_TIMESTAMP* = 3     # CLI option values
   SQL_FALSE* = 0
-  SQL_TRUE* = 1               # values of NULLABLE field in descriptor 
+  SQL_TRUE* = 1               # values of NULLABLE field in descriptor
   SQL_NO_NULLS* = 0
   SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
-                    # not known whether or not a data type supports null values. 
-  SQL_NULLABLE_UNKNOWN* = 2 
+                    # not known whether or not a data type supports null values.
+  SQL_NULLABLE_UNKNOWN* = 2
   SQL_CLOSE* = 0
   SQL_DROP* = 1
   SQL_UNBIND* = 2
   SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
-                        #   and in SQLDataSources() 
+                        #   and in SQLDataSources()
   SQL_FETCH_NEXT* = 1
   SQL_FETCH_FIRST* = 2
   SQL_FETCH_FIRST_USER* = 31
-  SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll() 
+  SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll()
   SQL_FETCH_LAST* = 3
   SQL_FETCH_PRIOR* = 4
   SQL_FETCH_ABSOLUTE* = 5
-  SQL_FETCH_RELATIVE* = 6   
+  SQL_FETCH_RELATIVE* = 6
   SQL_NULL_HENV* = SqlHEnv(nil)
   SQL_NULL_HDBC* = SqlHDBC(nil)
   SQL_NULL_HSTMT* = SqlHStmt(nil)
@@ -529,7 +537,7 @@ const
   SQL_SCOPE_TRANSACTION* = 1
   SQL_SCOPE_SESSION* = 2      #* Column types and scopes in SQLSpecialColumns.  */
   SQL_BEST_ROWID* = 1
-  SQL_ROWVER* = 2             
+  SQL_ROWVER* = 2
   SQL_ROW_IDENTIFIER* = 1     #* Reserved values for UNIQUE argument of SQLStatistics() */
   SQL_INDEX_UNIQUE* = 0
   SQL_INDEX_ALL* = 1          #* Reserved values for RESERVED argument of SQLStatistics() */
@@ -538,13 +546,13 @@ const
   SQL_TABLE_STAT* = 0
   SQL_INDEX_CLUSTERED* = 1
   SQL_INDEX_HASHED* = 2
-  SQL_INDEX_OTHER* = 3 
+  SQL_INDEX_OTHER* = 3
   SQL_SCROLL_CONCURRENCY* = 43
   SQL_TXN_CAPABLE* = 46
   SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
   SQL_USER_NAME* = 47
   SQL_TXN_ISOLATION_OPTION* = 72
-  SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION 
+  SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION
   SQL_OJ_CAPABILITIES* = 115
   SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
   SQL_XOPEN_CLI_YEAR* = 10000
@@ -570,10 +578,10 @@ const
   SQL_TXN_REPEATABLE_READ* = 4
   SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
   SQL_TXN_SERIALIZABLE* = 8
-  SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE 
+  SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE
   SQL_SS_ADDITIONS* = 1
   SQL_SS_DELETIONS* = 2
-  SQL_SS_UPDATES* = 4         # SQLColAttributes defines 
+  SQL_SS_UPDATES* = 4         # SQLColAttributes defines
   SQL_COLUMN_COUNT* = 0
   SQL_COLUMN_NAME* = 1
   SQL_COLUMN_TYPE* = 2
@@ -633,166 +641,166 @@ const
   ODBC_CONFIG_SYS_DSN* = 5
   ODBC_REMOVE_SYS_DSN* = 6
 
-proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle, 
+proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle,
                      OutputHandlePtr: var SqlHandle): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger, 
+proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
                     Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger, 
-                    Value: SqlPointer, BufferLength: TSqlInteger, 
-                    StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
+                    Value: SqlPointer, BufferLength: TSqlInteger,
+                    StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
     importc.}
 proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: SqlHandle): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle, 
-                    RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR, 
-                    NativeError: var TSqlInteger, MessageText: PSQLCHAR, 
+proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle,
+                    RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR,
+                    NativeError: var TSqlInteger, MessageText: PSQLCHAR,
                     BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle, 
-                      RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, 
-                      DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt, 
+proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle,
+                      RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt,
+                      DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt,
                       StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR, 
-                 NameLength1: TSqlSmallInt, UserName: PSQLCHAR, 
-                 NameLength2: TSqlSmallInt, Authentication: PSQLCHAR, 
+proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR,
+                 NameLength1: TSqlSmallInt, UserName: PSQLCHAR,
+                 NameLength2: TSqlSmallInt, Authentication: PSQLCHAR,
                  NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring, 
-                       szCLen: TSqlSmallInt, szCsout: cstring, 
-                       cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, 
+proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring,
+                       szCLen: TSqlSmallInt, szCsout: cstring,
+                       cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt,
                        f: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR, 
-                       cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, 
-                       cbConnStrOutMax: TSqlSmallInt, 
+proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR,
+                       cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR,
+                       cbConnStrOutMax: TSqlSmallInt,
                        cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, 
+proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
                     TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, 
+proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
                  TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
 proc SQLExecute*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
 proc SQLFetch*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
 proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, 
-                     ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                     NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, 
-                     ColumnSize: var SqlUInteger, 
+proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
+                     ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
+                     NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
+                     ColumnSize: var SqlUInteger,
                      DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt, 
-                     FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
+                     FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt, 
-                       irow: TSqlInteger, pcrow: PSQLUINTEGER, 
-                       rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
+                       irow: TSqlInteger, pcrow: PSQLUINTEGER,
+                       rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: SqlPointer, 
+proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
+                 TargetType: TSqlSmallInt, TargetValue: SqlPointer,
                  BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger, 
+proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
                      Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger, 
-                     Value: SqlPointer, BufferLength: TSqlInteger, 
-                     StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
+                     Value: SqlPointer, BufferLength: TSqlInteger,
+                     StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt, 
-                 InfoValue: SqlPointer, BufferLength: TSqlSmallInt, 
-                 StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt,
+                 InfoValue: SqlPointer, BufferLength: TSqlSmallInt,
+                 StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
     importc.}
 proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer, 
+proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer,
                  StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: SqlPointer, 
+proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
+                 TargetType: TSqlSmallInt, TargetValue: SqlPointer,
                  BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt, 
+proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt,
                 fLock: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt, 
-                     ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                     NameLength1: PSQLSMALLINT, Description: PSQLCHAR, 
+proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
+                     ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt,
+                     NameLength1: PSQLSMALLINT, Description: PSQLCHAR,
                      BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt, 
-                 DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                 DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR, 
+proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
+                 DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt,
+                 DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR,
                  BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger, 
+proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger,
                         Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, 
+proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
                        BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, 
-                       NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
+                       NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
 proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt, 
-                       fParamType: TSqlSmallInt, fCType: TSqlSmallInt, 
-                       fSqlType: TSqlSmallInt, cbColDef: SqlUInteger, 
-                       ibScale: TSqlSmallInt, rgbValue: SqlPointer, 
+proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt,
+                       fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
+                       fSqlType: TSqlSmallInt, cbColDef: SqlUInteger,
+                       ibScale: TSqlSmallInt, rgbValue: SqlPointer,
                        cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
     dynlib: odbclib, importc.}
 proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, 
-                      FieldIdentifier: SqlUSmallInt, 
-                      CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                      StringLength: PSQLSMALLINT, 
+proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
+                      FieldIdentifier: SqlUSmallInt,
+                      CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
+                      StringLength: PSQLSMALLINT,
                       NumericAttribute: SqlPointer): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle, 
-                 CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle,
+                 CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, 
-                cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                cbTableName: TSqlSmallInt, szTableType: PSQLCHAR, 
+proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
+                cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
+                cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
+                cbTableName: TSqlSmallInt, szTableType: PSQLCHAR,
                 cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, 
-                 cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                 cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                 cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR, 
+proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
+                 cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
+                 cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
+                 cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR,
                  cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt, 
-                        CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, 
-                        SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, 
-                        TableName: PSQLCHAR, NameLength3: TSqlSmallInt, 
-                        Scope: SqlUSmallInt, 
+proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt,
+                        CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt,
+                        SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt,
+                        TableName: PSQLCHAR, NameLength3: TSqlSmallInt,
+                        Scope: SqlUSmallInt,
                         Nullable: SqlUSmallInt): TSqlSmallInt{.
     dynlib: odbclib, importc.}
-proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, 
-                    cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                    cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                    cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
+                    cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
+                    cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
+                    cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, 
-                     NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                     NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                     NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
+                     NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
+                     NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
+                     NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, 
-                          NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                          NameLength2: TSqlSmallInt, ProcName: PSQLCHAR, 
-                          NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR, 
-                          NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
+proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
+                          NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
+                          NameLength2: TSqlSmallInt, ProcName: PSQLCHAR,
+                          NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR,
+                          NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
     importc.}
-proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, 
-                    NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                    NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                    NameLength3: TSqlSmallInt, Unique: SqlUSmallInt, 
+proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
+                    NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
+                    NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
+                    NameLength3: TSqlSmallInt, Unique: SqlUSmallInt,
                     Reserved: SqlUSmallInt): TSqlSmallInt {.
                     dynlib: odbclib, importc.}
 
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 03729dbab..013f26943 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -1,41 +1,11 @@
-#==============================================================================#
-# Project: Ararat Synapse                                        | 003.004.001 #
-#==============================================================================#
-# Content: SSL support by OpenSSL                                              #
-#==============================================================================#
-# Copyright (c)1999-2005, Lukas Gebauer                                        #
-# All rights reserved.                                                         #
-#                                                                              #
-# Redistribution and use in source and binary forms, with or without           #
-# modification, are permitted provided that the following conditions are met:  #
-#                                                                              #
-# Redistributions of source code must retain the above copyright notice, this  #
-# list of conditions and the following disclaimer.                             #
-#                                                                              #
-# Redistributions in binary form must reproduce the above copyright notice,    #
-# this list of conditions and the following disclaimer in the documentation    #
-# and/or other materials provided with the distribution.                       #
-#                                                                              #
-# Neither the name of Lukas Gebauer nor the names of its contributors may      #
-# be used to endorse or promote products derived from this software without    #
-# specific prior written permission.                                           #
-#                                                                              #
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  #
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE    #
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE   #
-# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR  #
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL       #
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR   #
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER   #
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT           #
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY    #
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH  #
-# DAMAGE.                                                                      #
-#==============================================================================#
-# The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).#
-# Portions created by Lukas Gebauer are Copyright (c)2002-2005.                #
-# All Rights Reserved.                                                         #
-#==============================================================================#
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
 
 ## OpenSSL support
 
@@ -43,8 +13,8 @@
 
 const useWinVersion = defined(Windows) or defined(nimdoc)
 
-when useWinVersion: 
-  const 
+when useWinVersion:
+  const
     DLLSSLName = "(ssleay32|libssl32).dll"
     DLLUtilName = "libeay32.dll"
   from winlean import SocketHandle
@@ -56,12 +26,12 @@ else:
       DLLSSLName = "libssl" & versions & ".dylib"
       DLLUtilName = "libcrypto" & versions & ".dylib"
   else:
-    const 
+    const
       DLLSSLName = "libssl.so" & versions
       DLLUtilName = "libcrypto.so" & versions
   from posix import SocketHandle
 
-type 
+type
   SslStruct {.final, pure.} = object
   SslPtr* = ptr SslStruct
   PSslPtr* = ptr SslPtr
@@ -80,7 +50,7 @@ type
   PFunction* = proc () {.cdecl.}
   DES_cblock* = array[0..7, int8]
   PDES_cblock* = ptr DES_cblock
-  des_ks_struct*{.final.} = object 
+  des_ks_struct*{.final.} = object
     ks*: DES_cblock
     weak_key*: cInt
 
@@ -88,7 +58,7 @@ type
 
 {.deprecated: [PSSL: SslPtr, PSSL_CTX: SslCtx, PBIO: BIO].}
 
-const 
+const
   SSL_SENT_SHUTDOWN* = 1
   SSL_RECEIVED_SHUTDOWN* = 2
   EVP_MAX_MD_SIZE* = 16 + 20
@@ -116,8 +86,8 @@ const
   SSL_CTRL_GET_FLAGS* = 13
   SSL_CTRL_EXTRA_CHAIN_CERT* = 14
   SSL_CTRL_SET_MSG_CALLBACK* = 15
-  SSL_CTRL_SET_MSG_CALLBACK_ARG* = 16 # only applies to datagram connections  
-  SSL_CTRL_SET_MTU* = 17      # Stats  
+  SSL_CTRL_SET_MSG_CALLBACK_ARG* = 16 # only applies to datagram connections
+  SSL_CTRL_SET_MTU* = 17      # Stats
   SSL_CTRL_SESS_NUMBER* = 20
   SSL_CTRL_SESS_CONNECT* = 21
   SSL_CTRL_SESS_CONNECT_GOOD* = 22
@@ -204,7 +174,7 @@ const
   SSL_FILETYPE_ASN1* = 2
   SSL_FILETYPE_PEM* = 1
   EVP_PKEY_RSA* = 6           # libssl.dll
-  
+
   BIO_C_SET_CONNECT = 100
   BIO_C_DO_STATE_MACHINE = 101
   BIO_C_GET_SSL = 110
@@ -237,7 +207,7 @@ proc SSL_CTX_use_certificate_chain_file*(ctx: SslCtx, filename: cstring): cInt{.
     stdcall, dynlib: DLLSSLName, importc.}
 proc SSL_CTX_use_PrivateKey_file*(ctx: SslCtx,
     filename: cstring, typ: cInt): cInt{.cdecl, dynlib: DLLSSLName, importc.}
-proc SSL_CTX_check_private_key*(ctx: SslCtx): cInt{.cdecl, dynlib: DLLSSLName, 
+proc SSL_CTX_check_private_key*(ctx: SslCtx): cInt{.cdecl, dynlib: DLLSSLName,
     importc.}
 
 proc SSL_set_fd*(ssl: SslPtr, fd: SocketHandle): cint{.cdecl, dynlib: DLLSSLName, importc.}
@@ -256,7 +226,7 @@ proc BIO_new_ssl_connect*(ctx: SslCtx): BIO{.cdecl,
     dynlib: DLLSSLName, importc.}
 proc BIO_ctrl*(bio: BIO, cmd: cint, larg: int, arg: cstring): int{.cdecl,
     dynlib: DLLSSLName, importc.}
-proc BIO_get_ssl*(bio: BIO, ssl: ptr SslPtr): int = 
+proc BIO_get_ssl*(bio: BIO, ssl: ptr SslPtr): int =
   return BIO_ctrl(bio, BIO_C_GET_SSL, 0, cast[cstring](ssl))
 proc BIO_set_conn_hostname*(bio: BIO, name: cstring): int =
   return BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, name)
@@ -266,16 +236,16 @@ proc BIO_do_connect*(bio: BIO): int =
   return BIO_do_handshake(bio)
 
 when not defined(nimfix):
-  proc BIO_read*(b: BIO, data: cstring, length: cInt): cInt{.cdecl, 
+  proc BIO_read*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc BIO_write*(b: BIO, data: cstring, length: cInt): cInt{.cdecl, 
+  proc BIO_write*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
 
 proc BIO_free*(b: BIO): cInt{.cdecl, dynlib: DLLUtilName, importc.}
 
 proc ERR_print_errors_fp*(fp: File){.cdecl, dynlib: DLLSSLName, importc.}
 
-proc ERR_error_string*(e: cInt, buf: cstring): cstring{.cdecl, 
+proc ERR_error_string*(e: cInt, buf: cstring): cstring{.cdecl,
     dynlib: DLLUtilName, importc.}
 proc ERR_get_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
 proc ERR_peek_last_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
@@ -285,7 +255,7 @@ proc OpenSSL_add_all_algorithms*(){.cdecl, dynlib: DLLUtilName, importc: "OPENSS
 proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
 
 when not useWinVersion:
-  proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, 
+  proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
     dynlib: DLLUtilName, importc.}
 
   proc allocWrapper(size: int): pointer {.cdecl.} = alloc(size)
@@ -375,7 +345,7 @@ proc ErrRemoveState*(pid: cInt){.cdecl, dynlib: DLLUtilName, importc: "ERR_remov
 when true:
   discard
 else:
-  proc SslCtxSetCipherList*(arg0: PSSL_CTX, str: cstring): cInt{.cdecl, 
+  proc SslCtxSetCipherList*(arg0: PSSL_CTX, str: cstring): cInt{.cdecl,
       dynlib: DLLSSLName, importc.}
   proc SslCtxNew*(meth: PSSL_METHOD): PSSL_CTX{.cdecl,
       dynlib: DLLSSLName, importc.}
@@ -391,12 +361,12 @@ else:
   proc SslMethodV3*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
   proc SslMethodTLSV1*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
   proc SslMethodV23*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
-  proc SslCtxUsePrivateKey*(ctx: PSSL_CTX, pkey: SslPtr): cInt{.cdecl, 
+  proc SslCtxUsePrivateKey*(ctx: PSSL_CTX, pkey: SslPtr): cInt{.cdecl,
       dynlib: DLLSSLName, importc.}
   proc SslCtxUsePrivateKeyASN1*(pk: cInt, ctx: PSSL_CTX,
       d: cstring, length: int): cInt{.cdecl, dynlib: DLLSSLName, importc.}
 
-  proc SslCtxUseCertificate*(ctx: PSSL_CTX, x: SslPtr): cInt{.cdecl, 
+  proc SslCtxUseCertificate*(ctx: PSSL_CTX, x: SslPtr): cInt{.cdecl,
       dynlib: DLLSSLName, importc.}
   proc SslCtxUseCertificateASN1*(ctx: PSSL_CTX, length: int, d: cstring): cInt{.
       cdecl, dynlib: DLLSSLName, importc.}
@@ -404,9 +374,9 @@ else:
     #  function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const filename: PChar):cInt;
   proc SslCtxUseCertificateChainFile*(ctx: PSSL_CTX, filename: cstring): cInt{.
       cdecl, dynlib: DLLSSLName, importc.}
-  proc SslCtxSetDefaultPasswdCb*(ctx: PSSL_CTX, cb: PPasswdCb){.cdecl, 
+  proc SslCtxSetDefaultPasswdCb*(ctx: PSSL_CTX, cb: PPasswdCb){.cdecl,
       dynlib: DLLSSLName, importc.}
-  proc SslCtxSetDefaultPasswdCbUserdata*(ctx: PSSL_CTX, u: SslPtr){.cdecl, 
+  proc SslCtxSetDefaultPasswdCbUserdata*(ctx: PSSL_CTX, u: SslPtr){.cdecl,
       dynlib: DLLSSLName, importc.}
     #  function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):cInt;
   proc SslCtxLoadVerifyLocations*(ctx: PSSL_CTX, CAfile: cstring, CApath: cstring): cInt{.
@@ -416,15 +386,15 @@ else:
 
   proc SslConnect*(ssl: PSSL): cInt{.cdecl, dynlib: DLLSSLName, importc.}
 
-  
+
   proc SslGetVersion*(ssl: PSSL): cstring{.cdecl, dynlib: DLLSSLName, importc.}
-  proc SslGetPeerCertificate*(ssl: PSSL): PX509{.cdecl, dynlib: DLLSSLName, 
+  proc SslGetPeerCertificate*(ssl: PSSL): PX509{.cdecl, dynlib: DLLSSLName,
       importc.}
-  proc SslCtxSetVerify*(ctx: PSSL_CTX, mode: cInt, arg2: PFunction){.cdecl, 
+  proc SslCtxSetVerify*(ctx: PSSL_CTX, mode: cInt, arg2: PFunction){.cdecl,
       dynlib: DLLSSLName, importc.}
   proc SSLGetCurrentCipher*(s: PSSL): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
   proc SSLCipherGetName*(c: SslPtr): cstring{.cdecl, dynlib: DLLSSLName, importc.}
-  proc SSLCipherGetBits*(c: SslPtr, alg_bits: var cInt): cInt{.cdecl, 
+  proc SSLCipherGetBits*(c: SslPtr, alg_bits: var cInt): cInt{.cdecl,
       dynlib: DLLSSLName, importc.}
   proc SSLGetVerifyResult*(ssl: PSSL): int{.cdecl, dynlib: DLLSSLName, importc.}
     # libeay.dll
@@ -432,39 +402,39 @@ else:
   proc X509Free*(x: PX509){.cdecl, dynlib: DLLUtilName, importc.}
   proc X509NameOneline*(a: PX509_NAME, buf: cstring, size: cInt): cstring{.
       cdecl, dynlib: DLLUtilName, importc.}
-  proc X509GetSubjectName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName, 
+  proc X509GetSubjectName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
       importc.}
-  proc X509GetIssuerName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName, 
+  proc X509GetIssuerName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
       importc.}
   proc X509NameHash*(x: PX509_NAME): int{.cdecl, dynlib: DLLUtilName, importc.}
     #  function SslX509Digest(data: PX509; typ: PEVP_MD; md: PChar; len: PcInt):cInt;
   proc X509Digest*(data: PX509, typ: PEVP_MD, md: cstring, length: var cInt): cInt{.
       cdecl, dynlib: DLLUtilName, importc.}
   proc X509print*(b: PBIO, a: PX509): cInt{.cdecl, dynlib: DLLUtilName, importc.}
-  proc X509SetVersion*(x: PX509, version: cInt): cInt{.cdecl, dynlib: DLLUtilName, 
+  proc X509SetVersion*(x: PX509, version: cInt): cInt{.cdecl, dynlib: DLLUtilName,
       importc.}
-  proc X509SetPubkey*(x: PX509, pkey: EVP_PKEY): cInt{.cdecl, dynlib: DLLUtilName, 
+  proc X509SetPubkey*(x: PX509, pkey: EVP_PKEY): cInt{.cdecl, dynlib: DLLUtilName,
       importc.}
-  proc X509SetIssuerName*(x: PX509, name: PX509_NAME): cInt{.cdecl, 
+  proc X509SetIssuerName*(x: PX509, name: PX509_NAME): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc X509NameAddEntryByTxt*(name: PX509_NAME, field: cstring, typ: cInt, 
+  proc X509NameAddEntryByTxt*(name: PX509_NAME, field: cstring, typ: cInt,
                               bytes: cstring, length, loc, theSet: cInt): cInt{.
       cdecl, dynlib: DLLUtilName, importc.}
-  proc X509Sign*(x: PX509, pkey: EVP_PKEY, md: PEVP_MD): cInt{.cdecl, 
+  proc X509Sign*(x: PX509, pkey: EVP_PKEY, md: PEVP_MD): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc X509GmtimeAdj*(s: PASN1_UTCTIME, adj: cInt): PASN1_UTCTIME{.cdecl, 
+  proc X509GmtimeAdj*(s: PASN1_UTCTIME, adj: cInt): PASN1_UTCTIME{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc X509SetNotBefore*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl, 
+  proc X509SetNotBefore*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc X509SetNotAfter*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl, 
+  proc X509SetNotAfter*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc X509GetSerialNumber*(x: PX509): PASN1_cInt{.cdecl, dynlib: DLLUtilName, 
+  proc X509GetSerialNumber*(x: PX509): PASN1_cInt{.cdecl, dynlib: DLLUtilName,
       importc.}
   proc EvpPkeyNew*(): EVP_PKEY{.cdecl, dynlib: DLLUtilName, importc.}
   proc EvpPkeyFree*(pk: EVP_PKEY){.cdecl, dynlib: DLLUtilName, importc.}
-  proc EvpPkeyAssign*(pkey: EVP_PKEY, typ: cInt, key: Prsa): cInt{.cdecl, 
+  proc EvpPkeyAssign*(pkey: EVP_PKEY, typ: cInt, key: Prsa): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
-  proc EvpGetDigestByName*(Name: cstring): PEVP_MD{.cdecl, dynlib: DLLUtilName, 
+  proc EvpGetDigestByName*(Name: cstring): PEVP_MD{.cdecl, dynlib: DLLUtilName,
       importc.}
   proc EVPcleanup*(){.cdecl, dynlib: DLLUtilName, importc.}
     #  function ErrErrorString(e: cInt; buf: PChar): PChar;
@@ -475,7 +445,7 @@ else:
   proc CRYPTOcleanupAllExData*(){.cdecl, dynlib: DLLUtilName, importc.}
   proc RandScreen*(){.cdecl, dynlib: DLLUtilName, importc.}
 
-  proc d2iPKCS12bio*(b: PBIO, Pkcs12: SslPtr): SslPtr{.cdecl, dynlib: DLLUtilName, 
+  proc d2iPKCS12bio*(b: PBIO, Pkcs12: SslPtr): SslPtr{.cdecl, dynlib: DLLUtilName,
       importc.}
   proc PKCS12parse*(p12: SslPtr, pass: cstring, pkey, cert, ca: var SslPtr): cint{.
       dynlib: DLLUtilName, importc, cdecl.}
@@ -485,37 +455,37 @@ else:
       cdecl, dynlib: DLLUtilName, importc.}
   proc Asn1UtctimeNew*(): PASN1_UTCTIME{.cdecl, dynlib: DLLUtilName, importc.}
   proc Asn1UtctimeFree*(a: PASN1_UTCTIME){.cdecl, dynlib: DLLUtilName, importc.}
-  proc Asn1cIntSet*(a: PASN1_cInt, v: cInt): cInt{.cdecl, dynlib: DLLUtilName, 
+  proc Asn1cIntSet*(a: PASN1_cInt, v: cInt): cInt{.cdecl, dynlib: DLLUtilName,
       importc.}
   proc i2dX509bio*(b: PBIO, x: PX509): cInt{.cdecl, dynlib: DLLUtilName, importc.}
-  proc i2dPrivateKeyBio*(b: PBIO, pkey: EVP_PKEY): cInt{.cdecl, 
+  proc i2dPrivateKeyBio*(b: PBIO, pkey: EVP_PKEY): cInt{.cdecl,
       dynlib: DLLUtilName, importc.}
     # 3DES functions
   proc DESsetoddparity*(Key: des_cblock){.cdecl, dynlib: DLLUtilName, importc.}
   proc DESsetkeychecked*(key: des_cblock, schedule: des_key_schedule): cInt{.
       cdecl, dynlib: DLLUtilName, importc.}
-  proc DESecbencrypt*(Input: des_cblock, output: des_cblock, ks: des_key_schedule, 
+  proc DESecbencrypt*(Input: des_cblock, output: des_cblock, ks: des_key_schedule,
                       enc: cInt){.cdecl, dynlib: DLLUtilName, importc.}
   # implementation
 
-  proc SSLSetMode(s: PSSL, mode: int): int = 
+  proc SSLSetMode(s: PSSL, mode: int): int =
     result = SSLctrl(s, SSL_CTRL_MODE, mode, nil)
 
-  proc SSLCTXGetMode(ctx: PSSL_CTX): int = 
+  proc SSLCTXGetMode(ctx: PSSL_CTX): int =
     result = SSLCTXctrl(ctx, SSL_CTRL_MODE, 0, nil)
 
-  proc SSLGetMode(s: PSSL): int = 
+  proc SSLGetMode(s: PSSL): int =
     result = SSLctrl(s, SSL_CTRL_MODE, 0, nil)
 
 # <openssl/md5.h>
-type 
+type
   MD5_LONG* = cuint
-const 
+const
   MD5_CBLOCK* = 64
   MD5_LBLOCK* = int(MD5_CBLOCK div 4)
   MD5_DIGEST_LENGTH* = 16
-type 
-  MD5_CTX* = object 
+type
+  MD5_CTX* = object
     A,B,C,D,Nl,Nh: MD5_LONG
     data: array[MD5_LBLOCK, MD5_LONG]
     num: cuint
@@ -532,7 +502,7 @@ proc md5_Transform*(c: var MD5_CTX; b: ptr cuchar){.ic.}
 from strutils import toHex,toLower
 
 proc hexStr (buf:cstring): string =
-  # turn md5s output into a nice hex str 
+  # turn md5s output into a nice hex str
   result = newStringOfCap(32)
   for i in 0 .. <16:
     result.add toHex(buf[i].ord, 2).toLower
@@ -554,13 +524,13 @@ proc md5_File* (file: string): string {.raises: [IOError,Exception].} =
 
   discard md5_final( buf[0].addr, ctx )
   f.close
-  
+
   result = hexStr(buf)
 
 proc md5_Str* (str:string): string {.raises:[IOError].} =
   ##Generate MD5 hash for a string. Result is a 32 character
   #hex string with lowercase characters
-  var 
+  var
     ctx: MD5_CTX
     res: array[MD5_DIGEST_LENGTH,char]
     input = str.cstring
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
index 67436f026..4b6acce01 100644
--- a/lib/wrappers/pcre.nim
+++ b/lib/wrappers/pcre.nim
@@ -1,38 +1,11 @@
-#************************************************
-#       Perl-Compatible Regular Expressions     *
-#************************************************
-# This is the public header file for the PCRE library, to be #included by
-# applications that call the PCRE functions.
 #
-#           Copyright (c) 1997-2014 University of Cambridge
 #
-#-----------------------------------------------------------------------------
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
-#    * Redistributions of source code must retain the above copyright notice,
-#      this list of conditions and the following disclaimer.
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
 #
-#    * Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#    * Neither the name of the University of Cambridge nor the names of its
-#      contributors may be used to endorse or promote products derived from
-#      this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#-----------------------------------------------------------------------------
 
 {.deadCodeElim: on.}
 
@@ -77,9 +50,9 @@ const
 # C4   Affects compile, exec, dfa_exec, study
 # C5   Affects compile, exec, study
 #
-# Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged 
-# with E and D, respectively. They take precedence over C3, C4, and C5 settings 
-# passed from pcre_compile(). Those that are compatible with JIT execution are 
+# Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged
+# with E and D, respectively. They take precedence over C3, C4, and C5 settings
+# passed from pcre_compile(). Those that are compatible with JIT execution are
 # flagged with J.
 
 const
diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim
index 7e7a6c47f..74993c515 100644
--- a/lib/wrappers/pdcurses.nim
+++ b/lib/wrappers/pdcurses.nim
@@ -1,3 +1,12 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
 {.deadCodeElim: on.}
 
 discard """
@@ -32,7 +41,7 @@ pdcwin.h:
 
 when defined(windows):
   import windows
-  
+
   const
     pdcursesdll = "pdcurses.dll"
     unixOS = false
@@ -47,13 +56,13 @@ type
   cunsignedchar = char
   cunsignedlong = uint32
 
-const 
+const
   BUILD* = 3401
-  PDCURSES* = 1               # PDCurses-only routines 
-  XOPEN* = 1                  # X/Open Curses routines 
-  SYSVcurses* = 1             # System V Curses routines 
-  BSDcurses* = 1              # BSD Curses routines 
-  CHTYPE_LONG* = 1            # size of chtype; long 
+  PDCURSES* = 1               # PDCurses-only routines
+  XOPEN* = 1                  # X/Open Curses routines
+  SYSVcurses* = 1             # System V Curses routines
+  BSDcurses* = 1              # BSD Curses routines
+  CHTYPE_LONG* = 1            # size of chtype; long
   ERR* = (- 1)
   OK* = 0
   BUTTON_RELEASED* = 0x00000000
@@ -61,10 +70,10 @@ const
   BUTTON_CLICKED* = 0x00000002
   BUTTON_DOUBLE_CLICKED* = 0x00000003
   BUTTON_TRIPLE_CLICKED* = 0x00000004
-  BUTTON_MOVED* = 0x00000005  # PDCurses 
-  WHEEL_SCROLLED* = 0x00000006 # PDCurses 
-  BUTTON_ACTION_MASK* = 0x00000007 # PDCurses 
-  BUTTON_MODIFIER_MASK* = 0x00000038 # PDCurses 
+  BUTTON_MOVED* = 0x00000005  # PDCurses
+  WHEEL_SCROLLED* = 0x00000006 # PDCurses
+  BUTTON_ACTION_MASK* = 0x00000007 # PDCurses
+  BUTTON_MODIFIER_MASK* = 0x00000038 # PDCurses
   MOUSE_MOVED* = 0x00000008
   MOUSE_POSITION* = 0x00000010
   MOUSE_WHEEL_UP* = 0x00000020
@@ -74,19 +83,19 @@ const
   BUTTON1_CLICKED* = 0x00000004
   BUTTON1_DOUBLE_CLICKED* = 0x00000008
   BUTTON1_TRIPLE_CLICKED* = 0x00000010
-  BUTTON1_MOVED* = 0x00000010 # PDCurses 
+  BUTTON1_MOVED* = 0x00000010 # PDCurses
   BUTTON2_RELEASED* = 0x00000020
   BUTTON2_PRESSED* = 0x00000040
   BUTTON2_CLICKED* = 0x00000080
   BUTTON2_DOUBLE_CLICKED* = 0x00000100
   BUTTON2_TRIPLE_CLICKED* = 0x00000200
-  BUTTON2_MOVED* = 0x00000200 # PDCurses 
+  BUTTON2_MOVED* = 0x00000200 # PDCurses
   BUTTON3_RELEASED* = 0x00000400
   BUTTON3_PRESSED* = 0x00000800
   BUTTON3_CLICKED* = 0x00001000
   BUTTON3_DOUBLE_CLICKED* = 0x00002000
   BUTTON3_TRIPLE_CLICKED* = 0x00004000
-  BUTTON3_MOVED* = 0x00004000 # PDCurses 
+  BUTTON3_MOVED* = 0x00004000 # PDCurses
   BUTTON4_RELEASED* = 0x00008000
   BUTTON4_PRESSED* = 0x00010000
   BUTTON4_CLICKED* = 0x00020000
@@ -97,10 +106,10 @@ const
   BUTTON5_CLICKED* = 0x00400000
   BUTTON5_DOUBLE_CLICKED* = 0x00800000
   BUTTON5_TRIPLE_CLICKED* = 0x01000000
-  MOUSE_WHEEL_SCROLL* = 0x02000000 # PDCurses 
-  BUTTON_MODIFIER_SHIFT* = 0x04000000 # PDCurses 
-  BUTTON_MODIFIER_CONTROL* = 0x08000000 # PDCurses 
-  BUTTON_MODIFIER_ALT* = 0x10000000 # PDCurses 
+  MOUSE_WHEEL_SCROLL* = 0x02000000 # PDCurses
+  BUTTON_MODIFIER_SHIFT* = 0x04000000 # PDCurses
+  BUTTON_MODIFIER_CONTROL* = 0x08000000 # PDCurses
+  BUTTON_MODIFIER_ALT* = 0x10000000 # PDCurses
   ALL_MOUSE_EVENTS* = 0x1FFFFFFF
   REPORT_MOUSE_POSITION* = 0x20000000
   A_NORMAL* = 0
@@ -119,11 +128,11 @@ const
   A_PROTECT* = (A_UNDERLINE or A_LEFTLINE or A_RIGHTLINE)
   ATTR_SHIFT* = 19
   COLOR_SHIFT* = 24
-  A_STANDOUT* = (A_REVERSE or A_BOLD) # X/Open 
+  A_STANDOUT* = (A_REVERSE or A_BOLD) # X/Open
   A_DIM* = A_NORMAL
-  CHR_MSK* = A_CHARTEXT       # Obsolete 
-  ATR_MSK* = A_ATTRIBUTES     # Obsolete 
-  ATR_NRM* = A_NORMAL         # Obsolete 
+  CHR_MSK* = A_CHARTEXT       # Obsolete
+  ATR_MSK* = A_ATTRIBUTES     # Obsolete
+  ATR_NRM* = A_NORMAL         # Obsolete
   WA_ALTCHARSET* = A_ALTCHARSET
   WA_BLINK* = A_BLINK
   WA_BOLD* = A_BOLD
@@ -147,93 +156,93 @@ const
   COLOR_MAGENTA* = (COLOR_RED or COLOR_BLUE)
   COLOR_YELLOW* = (COLOR_RED or COLOR_GREEN)
   COLOR_WHITE* = 7
-  KEY_CODE_YES* = 0x00000100  # If get_wch() gives a key code 
-  KEY_BREAK* = 0x00000101     # Not on PC KBD 
-  KEY_DOWN* = 0x00000102      # Down arrow key 
-  KEY_UP* = 0x00000103        # Up arrow key 
-  KEY_LEFT* = 0x00000104      # Left arrow key 
-  KEY_RIGHT* = 0x00000105     # Right arrow key 
-  KEY_HOME* = 0x00000106      # home key 
-  KEY_BACKSPACE* = 0x00000107 # not on pc 
-  KEY_F0* = 0x00000108        # function keys; 64 reserved 
-  KEY_DL* = 0x00000148        # delete line 
-  KEY_IL* = 0x00000149        # insert line 
-  KEY_DC* = 0x0000014A        # delete character 
-  KEY_IC* = 0x0000014B        # insert char or enter ins mode 
-  KEY_EIC* = 0x0000014C       # exit insert char mode 
-  KEY_CLEAR* = 0x0000014D     # clear screen 
-  KEY_EOS* = 0x0000014E       # clear to end of screen 
-  KEY_EOL* = 0x0000014F       # clear to end of line 
-  KEY_SF* = 0x00000150        # scroll 1 line forward 
-  KEY_SR* = 0x00000151        # scroll 1 line back (reverse) 
-  KEY_NPAGE* = 0x00000152     # next page 
-  KEY_PPAGE* = 0x00000153     # previous page 
-  KEY_STAB* = 0x00000154      # set tab 
-  KEY_CTAB* = 0x00000155      # clear tab 
-  KEY_CATAB* = 0x00000156     # clear all tabs 
-  KEY_ENTER* = 0x00000157     # enter or send (unreliable) 
-  KEY_SRESET* = 0x00000158    # soft/reset (partial/unreliable) 
-  KEY_RESET* = 0x00000159     # reset/hard reset (unreliable) 
-  KEY_PRINT* = 0x0000015A     # print/copy 
-  KEY_LL* = 0x0000015B        # home down/bottom (lower left) 
-  KEY_ABORT* = 0x0000015C     # abort/terminate key (any) 
-  KEY_SHELP* = 0x0000015D     # short help 
-  KEY_LHELP* = 0x0000015E     # long help 
-  KEY_BTAB* = 0x0000015F      # Back tab key 
-  KEY_BEG* = 0x00000160       # beg(inning) key 
-  KEY_CANCEL* = 0x00000161    # cancel key 
-  KEY_CLOSE* = 0x00000162     # close key 
-  KEY_COMMAND* = 0x00000163   # cmd (command) key 
-  KEY_COPY* = 0x00000164      # copy key 
-  KEY_CREATE* = 0x00000165    # create key 
-  KEY_END* = 0x00000166       # end key 
-  KEY_EXIT* = 0x00000167      # exit key 
-  KEY_FIND* = 0x00000168      # find key 
-  KEY_HELP* = 0x00000169      # help key 
-  KEY_MARK* = 0x0000016A      # mark key 
-  KEY_MESSAGE* = 0x0000016B   # message key 
-  KEY_MOVE* = 0x0000016C      # move key 
-  KEY_NEXT* = 0x0000016D      # next object key 
-  KEY_OPEN* = 0x0000016E      # open key 
-  KEY_OPTIONS* = 0x0000016F   # options key 
-  KEY_PREVIOUS* = 0x00000170  # previous object key 
-  KEY_REDO* = 0x00000171      # redo key 
-  KEY_REFERENCE* = 0x00000172 # ref(erence) key 
-  KEY_REFRESH* = 0x00000173   # refresh key 
-  KEY_REPLACE* = 0x00000174   # replace key 
-  KEY_RESTART* = 0x00000175   # restart key 
-  KEY_RESUME* = 0x00000176    # resume key 
-  KEY_SAVE* = 0x00000177      # save key 
-  KEY_SBEG* = 0x00000178      # shifted beginning key 
-  KEY_SCANCEL* = 0x00000179   # shifted cancel key 
-  KEY_SCOMMAND* = 0x0000017A  # shifted command key 
-  KEY_SCOPY* = 0x0000017B     # shifted copy key 
-  KEY_SCREATE* = 0x0000017C   # shifted create key 
-  KEY_SDC* = 0x0000017D       # shifted delete char key 
-  KEY_SDL* = 0x0000017E       # shifted delete line key 
-  KEY_SELECT* = 0x0000017F    # select key 
-  KEY_SEND* = 0x00000180      # shifted end key 
-  KEY_SEOL* = 0x00000181      # shifted clear line key 
-  KEY_SEXIT* = 0x00000182     # shifted exit key 
-  KEY_SFIND* = 0x00000183     # shifted find key 
-  KEY_SHOME* = 0x00000184     # shifted home key 
-  KEY_SIC* = 0x00000185       # shifted input key 
-  KEY_SLEFT* = 0x00000187     # shifted left arrow key 
-  KEY_SMESSAGE* = 0x00000188  # shifted message key 
-  KEY_SMOVE* = 0x00000189     # shifted move key 
-  KEY_SNEXT* = 0x0000018A     # shifted next key 
-  KEY_SOPTIONS* = 0x0000018B  # shifted options key 
-  KEY_SPREVIOUS* = 0x0000018C # shifted prev key 
-  KEY_SPRINT* = 0x0000018D    # shifted print key 
-  KEY_SREDO* = 0x0000018E     # shifted redo key 
-  KEY_SREPLACE* = 0x0000018F  # shifted replace key 
-  KEY_SRIGHT* = 0x00000190    # shifted right arrow 
-  KEY_SRSUME* = 0x00000191    # shifted resume key 
-  KEY_SSAVE* = 0x00000192     # shifted save key 
-  KEY_SSUSPEND* = 0x00000193  # shifted suspend key 
-  KEY_SUNDO* = 0x00000194     # shifted undo key 
-  KEY_SUSPEND* = 0x00000195   # suspend key 
-  KEY_UNDO* = 0x00000196      # undo key 
+  KEY_CODE_YES* = 0x00000100  # If get_wch() gives a key code
+  KEY_BREAK* = 0x00000101     # Not on PC KBD
+  KEY_DOWN* = 0x00000102      # Down arrow key
+  KEY_UP* = 0x00000103        # Up arrow key
+  KEY_LEFT* = 0x00000104      # Left arrow key
+  KEY_RIGHT* = 0x00000105     # Right arrow key
+  KEY_HOME* = 0x00000106      # home key
+  KEY_BACKSPACE* = 0x00000107 # not on pc
+  KEY_F0* = 0x00000108        # function keys; 64 reserved
+  KEY_DL* = 0x00000148        # delete line
+  KEY_IL* = 0x00000149        # insert line
+  KEY_DC* = 0x0000014A        # delete character
+  KEY_IC* = 0x0000014B        # insert char or enter ins mode
+  KEY_EIC* = 0x0000014C       # exit insert char mode
+  KEY_CLEAR* = 0x0000014D     # clear screen
+  KEY_EOS* = 0x0000014E       # clear to end of screen
+  KEY_EOL* = 0x0000014F       # clear to end of line
+  KEY_SF* = 0x00000150        # scroll 1 line forward
+  KEY_SR* = 0x00000151        # scroll 1 line back (reverse)
+  KEY_NPAGE* = 0x00000152     # next page
+  KEY_PPAGE* = 0x00000153     # previous page
+  KEY_STAB* = 0x00000154      # set tab
+  KEY_CTAB* = 0x00000155      # clear tab
+  KEY_CATAB* = 0x00000156     # clear all tabs
+  KEY_ENTER* = 0x00000157     # enter or send (unreliable)
+  KEY_SRESET* = 0x00000158    # soft/reset (partial/unreliable)
+  KEY_RESET* = 0x00000159     # reset/hard reset (unreliable)
+  KEY_PRINT* = 0x0000015A     # print/copy
+  KEY_LL* = 0x0000015B        # home down/bottom (lower left)
+  KEY_ABORT* = 0x0000015C     # abort/terminate key (any)
+  KEY_SHELP* = 0x0000015D     # short help
+  KEY_LHELP* = 0x0000015E     # long help
+  KEY_BTAB* = 0x0000015F      # Back tab key
+  KEY_BEG* = 0x00000160       # beg(inning) key
+  KEY_CANCEL* = 0x00000161    # cancel key
+  KEY_CLOSE* = 0x00000162     # close key
+  KEY_COMMAND* = 0x00000163   # cmd (command) key
+  KEY_COPY* = 0x00000164      # copy key
+  KEY_CREATE* = 0x00000165    # create key
+  KEY_END* = 0x00000166       # end key
+  KEY_EXIT* = 0x00000167      # exit key
+  KEY_FIND* = 0x00000168      # find key
+  KEY_HELP* = 0x00000169      # help key
+  KEY_MARK* = 0x0000016A      # mark key
+  KEY_MESSAGE* = 0x0000016B   # message key
+  KEY_MOVE* = 0x0000016C      # move key
+  KEY_NEXT* = 0x0000016D      # next object key
+  KEY_OPEN* = 0x0000016E      # open key
+  KEY_OPTIONS* = 0x0000016F   # options key
+  KEY_PREVIOUS* = 0x00000170  # previous object key
+  KEY_REDO* = 0x00000171      # redo key
+  KEY_REFERENCE* = 0x00000172 # ref(erence) key
+  KEY_REFRESH* = 0x00000173   # refresh key
+  KEY_REPLACE* = 0x00000174   # replace key
+  KEY_RESTART* = 0x00000175   # restart key
+  KEY_RESUME* = 0x00000176    # resume key
+  KEY_SAVE* = 0x00000177      # save key
+  KEY_SBEG* = 0x00000178      # shifted beginning key
+  KEY_SCANCEL* = 0x00000179   # shifted cancel key
+  KEY_SCOMMAND* = 0x0000017A  # shifted command key
+  KEY_SCOPY* = 0x0000017B     # shifted copy key
+  KEY_SCREATE* = 0x0000017C   # shifted create key
+  KEY_SDC* = 0x0000017D       # shifted delete char key
+  KEY_SDL* = 0x0000017E       # shifted delete line key
+  KEY_SELECT* = 0x0000017F    # select key
+  KEY_SEND* = 0x00000180      # shifted end key
+  KEY_SEOL* = 0x00000181      # shifted clear line key
+  KEY_SEXIT* = 0x00000182     # shifted exit key
+  KEY_SFIND* = 0x00000183     # shifted find key
+  KEY_SHOME* = 0x00000184     # shifted home key
+  KEY_SIC* = 0x00000185       # shifted input key
+  KEY_SLEFT* = 0x00000187     # shifted left arrow key
+  KEY_SMESSAGE* = 0x00000188  # shifted message key
+  KEY_SMOVE* = 0x00000189     # shifted move key
+  KEY_SNEXT* = 0x0000018A     # shifted next key
+  KEY_SOPTIONS* = 0x0000018B  # shifted options key
+  KEY_SPREVIOUS* = 0x0000018C # shifted prev key
+  KEY_SPRINT* = 0x0000018D    # shifted print key
+  KEY_SREDO* = 0x0000018E     # shifted redo key
+  KEY_SREPLACE* = 0x0000018F  # shifted replace key
+  KEY_SRIGHT* = 0x00000190    # shifted right arrow
+  KEY_SRSUME* = 0x00000191    # shifted resume key
+  KEY_SSAVE* = 0x00000192     # shifted save key
+  KEY_SSUSPEND* = 0x00000193  # shifted suspend key
+  KEY_SUNDO* = 0x00000194     # shifted undo key
+  KEY_SUSPEND* = 0x00000195   # suspend key
+  KEY_UNDO* = 0x00000196      # undo key
   ALT_0* = 0x00000197
   ALT_1* = 0x00000198
   ALT_2* = 0x00000199
@@ -270,46 +279,46 @@ const
   ALT_X* = 0x000001B8
   ALT_Y* = 0x000001B9
   ALT_Z* = 0x000001BA
-  CTL_LEFT* = 0x000001BB      # Control-Left-Arrow 
+  CTL_LEFT* = 0x000001BB      # Control-Left-Arrow
   CTL_RIGHT* = 0x000001BC
   CTL_PGUP* = 0x000001BD
   CTL_PGDN* = 0x000001BE
   CTL_HOME* = 0x000001BF
   CTL_END* = 0x000001C0
-  KEY_A1* = 0x000001C1        # upper left on Virtual keypad 
-  KEY_A2* = 0x000001C2        # upper middle on Virt. keypad 
-  KEY_A3* = 0x000001C3        # upper right on Vir. keypad 
-  KEY_B1* = 0x000001C4        # middle left on Virt. keypad 
-  KEY_B2* = 0x000001C5        # center on Virt. keypad 
-  KEY_B3* = 0x000001C6        # middle right on Vir. keypad 
-  KEY_C1* = 0x000001C7        # lower left on Virt. keypad 
-  KEY_C2* = 0x000001C8        # lower middle on Virt. keypad 
-  KEY_C3* = 0x000001C9        # lower right on Vir. keypad 
-  PADSLASH* = 0x000001CA      # slash on keypad 
-  PADENTER* = 0x000001CB      # enter on keypad 
-  CTL_PADENTER* = 0x000001CC  # ctl-enter on keypad 
-  ALT_PADENTER* = 0x000001CD  # alt-enter on keypad 
-  PADSTOP* = 0x000001CE       # stop on keypad 
-  PADSTAR* = 0x000001CF       # star on keypad 
-  PADMINUS* = 0x000001D0      # minus on keypad 
-  PADPLUS* = 0x000001D1       # plus on keypad 
-  CTL_PADSTOP* = 0x000001D2   # ctl-stop on keypad 
-  CTL_PADCENTER* = 0x000001D3 # ctl-enter on keypad 
-  CTL_PADPLUS* = 0x000001D4   # ctl-plus on keypad 
-  CTL_PADMINUS* = 0x000001D5  # ctl-minus on keypad 
-  CTL_PADSLASH* = 0x000001D6  # ctl-slash on keypad 
-  CTL_PADSTAR* = 0x000001D7   # ctl-star on keypad 
-  ALT_PADPLUS* = 0x000001D8   # alt-plus on keypad 
-  ALT_PADMINUS* = 0x000001D9  # alt-minus on keypad 
-  ALT_PADSLASH* = 0x000001DA  # alt-slash on keypad 
-  ALT_PADSTAR* = 0x000001DB   # alt-star on keypad 
-  ALT_PADSTOP* = 0x000001DC   # alt-stop on keypad 
-  CTL_INS* = 0x000001DD       # ctl-insert 
-  ALT_DEL* = 0x000001DE       # alt-delete 
-  ALT_INS* = 0x000001DF       # alt-insert 
-  CTL_UP* = 0x000001E0        # ctl-up arrow 
-  CTL_DOWN* = 0x000001E1      # ctl-down arrow 
-  CTL_TAB* = 0x000001E2       # ctl-tab 
+  KEY_A1* = 0x000001C1        # upper left on Virtual keypad
+  KEY_A2* = 0x000001C2        # upper middle on Virt. keypad
+  KEY_A3* = 0x000001C3        # upper right on Vir. keypad
+  KEY_B1* = 0x000001C4        # middle left on Virt. keypad
+  KEY_B2* = 0x000001C5        # center on Virt. keypad
+  KEY_B3* = 0x000001C6        # middle right on Vir. keypad
+  KEY_C1* = 0x000001C7        # lower left on Virt. keypad
+  KEY_C2* = 0x000001C8        # lower middle on Virt. keypad
+  KEY_C3* = 0x000001C9        # lower right on Vir. keypad
+  PADSLASH* = 0x000001CA      # slash on keypad
+  PADENTER* = 0x000001CB      # enter on keypad
+  CTL_PADENTER* = 0x000001CC  # ctl-enter on keypad
+  ALT_PADENTER* = 0x000001CD  # alt-enter on keypad
+  PADSTOP* = 0x000001CE       # stop on keypad
+  PADSTAR* = 0x000001CF       # star on keypad
+  PADMINUS* = 0x000001D0      # minus on keypad
+  PADPLUS* = 0x000001D1       # plus on keypad
+  CTL_PADSTOP* = 0x000001D2   # ctl-stop on keypad
+  CTL_PADCENTER* = 0x000001D3 # ctl-enter on keypad
+  CTL_PADPLUS* = 0x000001D4   # ctl-plus on keypad
+  CTL_PADMINUS* = 0x000001D5  # ctl-minus on keypad
+  CTL_PADSLASH* = 0x000001D6  # ctl-slash on keypad
+  CTL_PADSTAR* = 0x000001D7   # ctl-star on keypad
+  ALT_PADPLUS* = 0x000001D8   # alt-plus on keypad
+  ALT_PADMINUS* = 0x000001D9  # alt-minus on keypad
+  ALT_PADSLASH* = 0x000001DA  # alt-slash on keypad
+  ALT_PADSTAR* = 0x000001DB   # alt-star on keypad
+  ALT_PADSTOP* = 0x000001DC   # alt-stop on keypad
+  CTL_INS* = 0x000001DD       # ctl-insert
+  ALT_DEL* = 0x000001DE       # alt-delete
+  ALT_INS* = 0x000001DF       # alt-insert
+  CTL_UP* = 0x000001E0        # ctl-up arrow
+  CTL_DOWN* = 0x000001E1      # ctl-down arrow
+  CTL_TAB* = 0x000001E2       # ctl-tab
   ALT_TAB* = 0x000001E3
   ALT_MINUS* = 0x000001E4
   ALT_EQUAL* = 0x000001E5
@@ -317,24 +326,24 @@ const
   ALT_PGUP* = 0x000001E7
   ALT_PGDN* = 0x000001E8
   ALT_END* = 0x000001E9
-  ALT_UP* = 0x000001EA        # alt-up arrow 
-  ALT_DOWN* = 0x000001EB      # alt-down arrow 
-  ALT_RIGHT* = 0x000001EC     # alt-right arrow 
-  ALT_LEFT* = 0x000001ED      # alt-left arrow 
-  ALT_ENTER* = 0x000001EE     # alt-enter 
-  ALT_ESC* = 0x000001EF       # alt-escape 
-  ALT_BQUOTE* = 0x000001F0    # alt-back quote 
-  ALT_LBRACKET* = 0x000001F1  # alt-left bracket 
-  ALT_RBRACKET* = 0x000001F2  # alt-right bracket 
-  ALT_SEMICOLON* = 0x000001F3 # alt-semi-colon 
-  ALT_FQUOTE* = 0x000001F4    # alt-forward quote 
-  ALT_COMMA* = 0x000001F5     # alt-comma 
-  ALT_STOP* = 0x000001F6      # alt-stop 
-  ALT_FSLASH* = 0x000001F7    # alt-forward slash 
-  ALT_BKSP* = 0x000001F8      # alt-backspace 
-  CTL_BKSP* = 0x000001F9      # ctl-backspace 
-  PAD0* = 0x000001FA          # keypad 0 
-  CTL_PAD0* = 0x000001FB      # ctl-keypad 0 
+  ALT_UP* = 0x000001EA        # alt-up arrow
+  ALT_DOWN* = 0x000001EB      # alt-down arrow
+  ALT_RIGHT* = 0x000001EC     # alt-right arrow
+  ALT_LEFT* = 0x000001ED      # alt-left arrow
+  ALT_ENTER* = 0x000001EE     # alt-enter
+  ALT_ESC* = 0x000001EF       # alt-escape
+  ALT_BQUOTE* = 0x000001F0    # alt-back quote
+  ALT_LBRACKET* = 0x000001F1  # alt-left bracket
+  ALT_RBRACKET* = 0x000001F2  # alt-right bracket
+  ALT_SEMICOLON* = 0x000001F3 # alt-semi-colon
+  ALT_FQUOTE* = 0x000001F4    # alt-forward quote
+  ALT_COMMA* = 0x000001F5     # alt-comma
+  ALT_STOP* = 0x000001F6      # alt-stop
+  ALT_FSLASH* = 0x000001F7    # alt-forward slash
+  ALT_BKSP* = 0x000001F8      # alt-backspace
+  CTL_BKSP* = 0x000001F9      # ctl-backspace
+  PAD0* = 0x000001FA          # keypad 0
+  CTL_PAD0* = 0x000001FB      # ctl-keypad 0
   CTL_PAD1* = 0x000001FC
   CTL_PAD2* = 0x000001FD
   CTL_PAD3* = 0x000001FE
@@ -344,7 +353,7 @@ const
   CTL_PAD7* = 0x00000202
   CTL_PAD8* = 0x00000203
   CTL_PAD9* = 0x00000204
-  ALT_PAD0* = 0x00000205      # alt-keypad 0 
+  ALT_PAD0* = 0x00000205      # alt-keypad 0
   ALT_PAD1* = 0x00000206
   ALT_PAD2* = 0x00000207
   ALT_PAD3* = 0x00000208
@@ -354,30 +363,30 @@ const
   ALT_PAD7* = 0x0000020C
   ALT_PAD8* = 0x0000020D
   ALT_PAD9* = 0x0000020E
-  CTL_DEL* = 0x0000020F       # clt-delete 
-  ALT_BSLASH* = 0x00000210    # alt-back slash 
-  CTL_ENTER* = 0x00000211     # ctl-enter 
-  SHF_PADENTER* = 0x00000212  # shift-enter on keypad 
-  SHF_PADSLASH* = 0x00000213  # shift-slash on keypad 
-  SHF_PADSTAR* = 0x00000214   # shift-star  on keypad 
-  SHF_PADPLUS* = 0x00000215   # shift-plus  on keypad 
-  SHF_PADMINUS* = 0x00000216  # shift-minus on keypad 
-  SHF_UP* = 0x00000217        # shift-up on keypad 
-  SHF_DOWN* = 0x00000218      # shift-down on keypad 
-  SHF_IC* = 0x00000219        # shift-insert on keypad 
-  SHF_DC* = 0x0000021A        # shift-delete on keypad 
-  KEY_MOUSE* = 0x0000021B     # "mouse" key 
-  KEY_SHIFT_L* = 0x0000021C   # Left-shift 
-  KEY_SHIFT_R* = 0x0000021D   # Right-shift 
-  KEY_CONTROL_L* = 0x0000021E # Left-control 
-  KEY_CONTROL_R* = 0x0000021F # Right-control 
-  KEY_ALT_L* = 0x00000220     # Left-alt 
-  KEY_ALT_R* = 0x00000221     # Right-alt 
-  KEY_RESIZE* = 0x00000222    # Window resize 
-  KEY_SUP* = 0x00000223       # Shifted up arrow 
-  KEY_SDOWN* = 0x00000224     # Shifted down arrow 
-  KEY_MIN* = KEY_BREAK        # Minimum curses key value 
-  KEY_MAX* = KEY_SDOWN        # Maximum curses key 
+  CTL_DEL* = 0x0000020F       # clt-delete
+  ALT_BSLASH* = 0x00000210    # alt-back slash
+  CTL_ENTER* = 0x00000211     # ctl-enter
+  SHF_PADENTER* = 0x00000212  # shift-enter on keypad
+  SHF_PADSLASH* = 0x00000213  # shift-slash on keypad
+  SHF_PADSTAR* = 0x00000214   # shift-star  on keypad
+  SHF_PADPLUS* = 0x00000215   # shift-plus  on keypad
+  SHF_PADMINUS* = 0x00000216  # shift-minus on keypad
+  SHF_UP* = 0x00000217        # shift-up on keypad
+  SHF_DOWN* = 0x00000218      # shift-down on keypad
+  SHF_IC* = 0x00000219        # shift-insert on keypad
+  SHF_DC* = 0x0000021A        # shift-delete on keypad
+  KEY_MOUSE* = 0x0000021B     # "mouse" key
+  KEY_SHIFT_L* = 0x0000021C   # Left-shift
+  KEY_SHIFT_R* = 0x0000021D   # Right-shift
+  KEY_CONTROL_L* = 0x0000021E # Left-control
+  KEY_CONTROL_R* = 0x0000021F # Right-control
+  KEY_ALT_L* = 0x00000220     # Left-alt
+  KEY_ALT_R* = 0x00000221     # Right-alt
+  KEY_RESIZE* = 0x00000222    # Window resize
+  KEY_SUP* = 0x00000223       # Shifted up arrow
+  KEY_SDOWN* = 0x00000224     # Shifted down arrow
+  KEY_MIN* = KEY_BREAK        # Minimum curses key value
+  KEY_MAX* = KEY_SDOWN        # Maximum curses key
   CLIP_SUCCESS* = 0
   CLIP_ACCESS_ERROR* = 1
   CLIP_EMPTY* = 2
@@ -394,58 +403,58 @@ when appType == "gui":
     BUTTON_CTRL* = BUTTON_MODIFIER_CONTROL
     BUTTON_ALT* = BUTTON_MODIFIER_ALT
 else:
-  const 
+  const
     BUTTON_SHIFT* = 0x00000008
     BUTTON_CONTROL* = 0x00000010
     BUTTON_ALT* = 0x00000020
 
-type 
-  TMOUSE_STATUS*{.pure, final.} = object 
-    x*: cint                  # absolute column, 0 based, measured in characters 
-    y*: cint                  # absolute row, 0 based, measured in characters 
-    button*: array[0..3 - 1, cshort] # state of each button 
-    changes*: cint            # flags indicating what has changed with the mouse 
-  
-  MEVENT*{.pure, final.} = object 
-    id*: cshort               # unused, always 0 
+type
+  TMOUSE_STATUS*{.pure, final.} = object
+    x*: cint                  # absolute column, 0 based, measured in characters
+    y*: cint                  # absolute row, 0 based, measured in characters
+    button*: array[0..3 - 1, cshort] # state of each button
+    changes*: cint            # flags indicating what has changed with the mouse
+
+  MEVENT*{.pure, final.} = object
+    id*: cshort               # unused, always 0
     x*: cint
     y*: cint
-    z*: cint                  # x, y same as TMOUSE_STATUS; z unused 
+    z*: cint                  # x, y same as TMOUSE_STATUS; z unused
     bstate*: cunsignedlong    # equivalent to changes + button[], but
-                              # in the same format as used for mousemask() 
-  
-  WINDOW*{.pure, final.} = object 
-    cury*: cint              # current pseudo-cursor 
+                              # in the same format as used for mousemask()
+
+  WINDOW*{.pure, final.} = object
+    cury*: cint              # current pseudo-cursor
     curx*: cint
-    maxy*: cint              # max window coordinates 
+    maxy*: cint              # max window coordinates
     maxx*: cint
-    begy*: cint              # origin on screen 
+    begy*: cint              # origin on screen
     begx*: cint
-    flags*: cint             # window properties 
-    attrs*: cunsignedlong    # standard attributes and colors 
-    bkgd*: cunsignedlong     # background, normally blank 
-    clear*: cunsignedchar    # causes clear at next refresh 
-    leaveit*: cunsignedchar  # leaves cursor where it is 
-    scroll*: cunsignedchar   # allows window scrolling 
-    nodelay*: cunsignedchar  # input character wait flag 
-    immed*: cunsignedchar    # immediate update flag 
-    sync*: cunsignedchar     # synchronise window ancestors 
-    use_keypad*: cunsignedchar # flags keypad key mode active 
-    y*: ptr ptr cunsignedlong # pointer to line pointer array 
-    firstch*: ptr cint       # first changed character in line 
-    lastch*: ptr cint        # last changed character in line 
-    tmarg*: cint             # top of scrolling region 
-    bmarg*: cint             # bottom of scrolling region 
-    delayms*: cint           # milliseconds of delay for getch() 
+    flags*: cint             # window properties
+    attrs*: cunsignedlong    # standard attributes and colors
+    bkgd*: cunsignedlong     # background, normally blank
+    clear*: cunsignedchar    # causes clear at next refresh
+    leaveit*: cunsignedchar  # leaves cursor where it is
+    scroll*: cunsignedchar   # allows window scrolling
+    nodelay*: cunsignedchar  # input character wait flag
+    immed*: cunsignedchar    # immediate update flag
+    sync*: cunsignedchar     # synchronise window ancestors
+    use_keypad*: cunsignedchar # flags keypad key mode active
+    y*: ptr ptr cunsignedlong # pointer to line pointer array
+    firstch*: ptr cint       # first changed character in line
+    lastch*: ptr cint        # last changed character in line
+    tmarg*: cint             # top of scrolling region
+    bmarg*: cint             # bottom of scrolling region
+    delayms*: cint           # milliseconds of delay for getch()
     parx*: cint
-    pary*: cint              # coords relative to parent (0,0) 
-    parent*: ptr WINDOW        # subwin's pointer to parent win 
-  
-  PANELOBS*{.pure, final.} = object 
+    pary*: cint              # coords relative to parent (0,0)
+    parent*: ptr WINDOW        # subwin's pointer to parent win
+
+  PANELOBS*{.pure, final.} = object
     above*: ptr PANELOBS
     pan*: ptr PANEL
 
-  PANEL*{.pure, final.} = object 
+  PANEL*{.pure, final.} = object
     win*: ptr WINDOW
     wstarty*: cint
     wendy*: cint
@@ -462,39 +471,39 @@ type
 
 when unixOS:
   type
-    SCREEN*{.pure, final.} = object 
-      alive*: cunsignedchar     # if initscr() called, and not endwin() 
-      autocr*: cunsignedchar    # if cr -> lf 
-      cbreak*: cunsignedchar    # if terminal unbuffered 
-      echo*: cunsignedchar      # if terminal echo 
-      raw_inp*: cunsignedchar   # raw input mode (v. cooked input) 
-      raw_out*: cunsignedchar   # raw output mode (7 v. 8 bits) 
-      audible*: cunsignedchar   # FALSE if the bell is visual 
-      mono*: cunsignedchar      # TRUE if current screen is mono 
-      resized*: cunsignedchar   # TRUE if TERM has been resized 
-      orig_attr*: cunsignedchar # TRUE if we have the original colors 
-      orig_fore*: cshort        # original screen foreground color 
-      orig_back*: cshort        # original screen foreground color 
-      cursrow*: cint            # position of physical cursor 
-      curscol*: cint            # position of physical cursor 
-      visibility*: cint         # visibility of cursor 
-      orig_cursor*: cint        # original cursor size 
-      lines*: cint              # new value for LINES 
-      cols*: cint               # new value for COLS 
-      trap_mbe*: cunsignedlong # trap these mouse button events 
-      map_mbe_to_key*: cunsignedlong # map mouse buttons to slk 
+    SCREEN*{.pure, final.} = object
+      alive*: cunsignedchar     # if initscr() called, and not endwin()
+      autocr*: cunsignedchar    # if cr -> lf
+      cbreak*: cunsignedchar    # if terminal unbuffered
+      echo*: cunsignedchar      # if terminal echo
+      raw_inp*: cunsignedchar   # raw input mode (v. cooked input)
+      raw_out*: cunsignedchar   # raw output mode (7 v. 8 bits)
+      audible*: cunsignedchar   # FALSE if the bell is visual
+      mono*: cunsignedchar      # TRUE if current screen is mono
+      resized*: cunsignedchar   # TRUE if TERM has been resized
+      orig_attr*: cunsignedchar # TRUE if we have the original colors
+      orig_fore*: cshort        # original screen foreground color
+      orig_back*: cshort        # original screen foreground color
+      cursrow*: cint            # position of physical cursor
+      curscol*: cint            # position of physical cursor
+      visibility*: cint         # visibility of cursor
+      orig_cursor*: cint        # original cursor size
+      lines*: cint              # new value for LINES
+      cols*: cint               # new value for COLS
+      trap_mbe*: cunsignedlong # trap these mouse button events
+      map_mbe_to_key*: cunsignedlong # map mouse buttons to slk
       mouse_wait*: cint # time to wait (in ms) for a button release after a press
-      slklines*: cint           # lines in use by slk_init() 
-      slk_winptr*: ptr WINDOW   # window for slk 
-      linesrippedoff*: cint     # lines ripped off via ripoffline() 
-      linesrippedoffontop*: cint # lines ripped off on top via ripoffline() 
-      delaytenths*: cint        # 1/10ths second to wait block getch() for 
-      preserve*: cunsignedchar # TRUE if screen background to be preserved 
-      restore*: cint           # specifies if screen background to be restored, and how 
-      save_key_modifiers*: cunsignedchar # TRUE if each key modifiers saved with each key press 
-      return_key_modifiers*: cunsignedchar # TRUE if modifier keys are returned as "real" keys 
+      slklines*: cint           # lines in use by slk_init()
+      slk_winptr*: ptr WINDOW   # window for slk
+      linesrippedoff*: cint     # lines ripped off via ripoffline()
+      linesrippedoffontop*: cint # lines ripped off on top via ripoffline()
+      delaytenths*: cint        # 1/10ths second to wait block getch() for
+      preserve*: cunsignedchar # TRUE if screen background to be preserved
+      restore*: cint           # specifies if screen background to be restored, and how
+      save_key_modifiers*: cunsignedchar # TRUE if each key modifiers saved with each key press
+      return_key_modifiers*: cunsignedchar # TRUE if modifier keys are returned as "real" keys
       key_code*: cunsignedchar # TRUE if last key is a special key;
-      XcurscrSize*: cint        # size of Xcurscr shared memory block 
+      XcurscrSize*: cint        # size of Xcurscr shared memory block
       sb_on*: cunsignedchar
       sb_viewport_y*: cint
       sb_viewport_x*: cint
@@ -502,43 +511,43 @@ when unixOS:
       sb_total_x*: cint
       sb_cur_y*: cint
       sb_cur_x*: cint
-      line_color*: cshort       # color of line attributes - default -1 
+      line_color*: cshort       # color of line attributes - default -1
   {.deprecated: [TSCREEN: SCREEN].}
 else:
   type
-    SCREEN*{.pure, final.} = object 
-      alive*: cunsignedchar     # if initscr() called, and not endwin() 
-      autocr*: cunsignedchar    # if cr -> lf 
-      cbreak*: cunsignedchar    # if terminal unbuffered 
-      echo*: cunsignedchar      # if terminal echo 
-      raw_inp*: cunsignedchar   # raw input mode (v. cooked input) 
-      raw_out*: cunsignedchar   # raw output mode (7 v. 8 bits) 
-      audible*: cunsignedchar   # FALSE if the bell is visual 
-      mono*: cunsignedchar      # TRUE if current screen is mono 
-      resized*: cunsignedchar   # TRUE if TERM has been resized 
-      orig_attr*: cunsignedchar # TRUE if we have the original colors 
-      orig_fore*: cshort        # original screen foreground color 
-      orig_back*: cshort        # original screen foreground color 
-      cursrow*: cint            # position of physical cursor 
-      curscol*: cint            # position of physical cursor 
-      visibility*: cint         # visibility of cursor 
-      orig_cursor*: cint        # original cursor size 
-      lines*: cint              # new value for LINES 
-      cols*: cint               # new value for COLS 
-      trap_mbe*: cunsignedlong # trap these mouse button events 
-      map_mbe_to_key*: cunsignedlong # map mouse buttons to slk 
+    SCREEN*{.pure, final.} = object
+      alive*: cunsignedchar     # if initscr() called, and not endwin()
+      autocr*: cunsignedchar    # if cr -> lf
+      cbreak*: cunsignedchar    # if terminal unbuffered
+      echo*: cunsignedchar      # if terminal echo
+      raw_inp*: cunsignedchar   # raw input mode (v. cooked input)
+      raw_out*: cunsignedchar   # raw output mode (7 v. 8 bits)
+      audible*: cunsignedchar   # FALSE if the bell is visual
+      mono*: cunsignedchar      # TRUE if current screen is mono
+      resized*: cunsignedchar   # TRUE if TERM has been resized
+      orig_attr*: cunsignedchar # TRUE if we have the original colors
+      orig_fore*: cshort        # original screen foreground color
+      orig_back*: cshort        # original screen foreground color
+      cursrow*: cint            # position of physical cursor
+      curscol*: cint            # position of physical cursor
+      visibility*: cint         # visibility of cursor
+      orig_cursor*: cint        # original cursor size
+      lines*: cint              # new value for LINES
+      cols*: cint               # new value for COLS
+      trap_mbe*: cunsignedlong # trap these mouse button events
+      map_mbe_to_key*: cunsignedlong # map mouse buttons to slk
       mouse_wait*: cint # time to wait (in ms) for a button release after a press
-      slklines*: cint           # lines in use by slk_init() 
-      slk_winptr*: ptr WINDOW   # window for slk 
-      linesrippedoff*: cint     # lines ripped off via ripoffline() 
-      linesrippedoffontop*: cint # lines ripped off on top via ripoffline() 
-      delaytenths*: cint        # 1/10ths second to wait block getch() for 
-      preserve*: cunsignedchar # TRUE if screen background to be preserved 
-      restore*: cint           # specifies if screen background to be restored, and how 
-      save_key_modifiers*: cunsignedchar # TRUE if each key modifiers saved with each key press 
-      return_key_modifiers*: cunsignedchar # TRUE if modifier keys are returned as "real" keys 
+      slklines*: cint           # lines in use by slk_init()
+      slk_winptr*: ptr WINDOW   # window for slk
+      linesrippedoff*: cint     # lines ripped off via ripoffline()
+      linesrippedoffontop*: cint # lines ripped off on top via ripoffline()
+      delaytenths*: cint        # 1/10ths second to wait block getch() for
+      preserve*: cunsignedchar # TRUE if screen background to be preserved
+      restore*: cint           # specifies if screen background to be restored, and how
+      save_key_modifiers*: cunsignedchar # TRUE if each key modifiers saved with each key press
+      return_key_modifiers*: cunsignedchar # TRUE if modifier keys are returned as "real" keys
       key_code*: cunsignedchar # TRUE if last key is a special key;
-      line_color*: cshort       # color of line attributes - default -1 
+      line_color*: cshort       # color of line attributes - default -1
   {.deprecated: [TSCREEN: SCREEN].}
 
 var
@@ -554,20 +563,20 @@ var
   acs_map*{.importc: "acs_map", dynlib: pdcursesdll.}: ptr cunsignedlong
   ttytype*{.importc: "ttytype", dynlib: pdcursesdll.}: cstring
 
-template BUTTON_CHANGED*(x: expr): expr = 
+template BUTTON_CHANGED*(x: expr): expr =
   (Mouse_status.changes and (1 shl ((x) - 1)))
 
-template BUTTON_STATUS*(x: expr): expr = 
+template BUTTON_STATUS*(x: expr): expr =
   (Mouse_status.button[(x) - 1])
 
 template ACS_PICK*(w, n: expr): expr = int32(w) or A_ALTCHARSET
 
 template KEY_F*(n: expr): expr = KEY_F0 + n
 
-template COLOR_PAIR*(n: expr): expr = 
+template COLOR_PAIR*(n: expr): expr =
   ((cunsignedlong(n) shl COLOR_SHIFT) and A_COLOR)
 
-template PAIR_NUMBER*(n: expr): expr = 
+template PAIR_NUMBER*(n: expr): expr =
   (((n) and A_COLOR) shr COLOR_SHIFT)
 
 const
@@ -665,75 +674,75 @@ discard """WACS_ULCORNER* = (addr((acs_map['l'])))
   WACS_SBSB* = WACS_VLINE
   WACS_SSSS* = WACS_PLUS"""
 
-proc addch*(a2: cunsignedlong): cint{.extdecl, importc: "addch", 
+proc addch*(a2: cunsignedlong): cint{.extdecl, importc: "addch",
                                       dynlib: pdcursesdll.}
-proc addchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc addchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "addchnstr", dynlib: pdcursesdll.}
-proc addchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "addchstr", 
+proc addchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "addchstr",
     dynlib: pdcursesdll.}
-proc addnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "addnstr", 
+proc addnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "addnstr",
     dynlib: pdcursesdll.}
 proc addstr*(a2: cstring): cint{.extdecl, importc: "addstr", dynlib: pdcursesdll.}
-proc attroff*(a2: cunsignedlong): cint{.extdecl, importc: "attroff", 
+proc attroff*(a2: cunsignedlong): cint{.extdecl, importc: "attroff",
                                         dynlib: pdcursesdll.}
-proc attron*(a2: cunsignedlong): cint{.extdecl, importc: "attron", 
+proc attron*(a2: cunsignedlong): cint{.extdecl, importc: "attron",
                                        dynlib: pdcursesdll.}
-proc attrset*(a2: cunsignedlong): cint{.extdecl, importc: "attrset", 
+proc attrset*(a2: cunsignedlong): cint{.extdecl, importc: "attrset",
                                         dynlib: pdcursesdll.}
-proc attr_get*(a2: ptr cunsignedlong; a3: ptr cshort; a4: pointer): cint{.extdecl, 
+proc attr_get*(a2: ptr cunsignedlong; a3: ptr cshort; a4: pointer): cint{.extdecl,
     importc: "attr_get", dynlib: pdcursesdll.}
-proc attr_off*(a2: cunsignedlong; a3: pointer): cint{.extdecl, 
+proc attr_off*(a2: cunsignedlong; a3: pointer): cint{.extdecl,
     importc: "attr_off", dynlib: pdcursesdll.}
-proc attr_on*(a2: cunsignedlong; a3: pointer): cint{.extdecl, importc: "attr_on", 
+proc attr_on*(a2: cunsignedlong; a3: pointer): cint{.extdecl, importc: "attr_on",
     dynlib: pdcursesdll.}
-proc attr_set*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl, 
+proc attr_set*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl,
     importc: "attr_set", dynlib: pdcursesdll.}
 proc baudrate*(): cint{.extdecl, importc: "baudrate", dynlib: pdcursesdll.}
 proc beep*(): cint{.extdecl, importc: "beep", dynlib: pdcursesdll.}
 proc bkgd*(a2: cunsignedlong): cint{.extdecl, importc: "bkgd", dynlib: pdcursesdll.}
 proc bkgdset*(a2: cunsignedlong){.extdecl, importc: "bkgdset", dynlib: pdcursesdll.}
-proc border*(a2: cunsignedlong; a3: cunsignedlong; a4: cunsignedlong; 
-             a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong; 
-             a8: cunsignedlong; a9: cunsignedlong): cint{.extdecl, 
+proc border*(a2: cunsignedlong; a3: cunsignedlong; a4: cunsignedlong;
+             a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong;
+             a8: cunsignedlong; a9: cunsignedlong): cint{.extdecl,
     importc: "border", dynlib: pdcursesdll.}
-proc box*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong): cint{.extdecl, 
+proc box*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong): cint{.extdecl,
     importc: "box", dynlib: pdcursesdll.}
-proc can_change_color*(): cunsignedchar{.extdecl, importc: "can_change_color", 
+proc can_change_color*(): cunsignedchar{.extdecl, importc: "can_change_color",
     dynlib: pdcursesdll.}
 proc cbreak*(): cint{.extdecl, importc: "cbreak", dynlib: pdcursesdll.}
-proc chgat*(a2: cint; a3: cunsignedlong; a4: cshort; a5: pointer): cint{.extdecl, 
+proc chgat*(a2: cint; a3: cunsignedlong; a4: cshort; a5: pointer): cint{.extdecl,
     importc: "chgat", dynlib: pdcursesdll.}
-proc clearok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc clearok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "clearok", dynlib: pdcursesdll.}
 proc clear*(): cint{.extdecl, importc: "clear", dynlib: pdcursesdll.}
 proc clrtobot*(): cint{.extdecl, importc: "clrtobot", dynlib: pdcursesdll.}
 proc clrtoeol*(): cint{.extdecl, importc: "clrtoeol", dynlib: pdcursesdll.}
 proc color_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort; a5: ptr cshort): cint{.
     extdecl, importc: "color_content", dynlib: pdcursesdll.}
-proc color_set*(a2: cshort; a3: pointer): cint{.extdecl, importc: "color_set", 
+proc color_set*(a2: cshort; a3: pointer): cint{.extdecl, importc: "color_set",
     dynlib: pdcursesdll.}
-proc copywin*(a2: ptr WINDOW; a3: ptr WINDOW; a4: cint; a5: cint; a6: cint; 
-              a7: cint; a8: cint; a9: cint; a10: cint): cint{.extdecl, 
+proc copywin*(a2: ptr WINDOW; a3: ptr WINDOW; a4: cint; a5: cint; a6: cint;
+              a7: cint; a8: cint; a9: cint; a10: cint): cint{.extdecl,
     importc: "copywin", dynlib: pdcursesdll.}
 proc curs_set*(a2: cint): cint{.extdecl, importc: "curs_set", dynlib: pdcursesdll.}
-proc def_prog_mode*(): cint{.extdecl, importc: "def_prog_mode", 
+proc def_prog_mode*(): cint{.extdecl, importc: "def_prog_mode",
                              dynlib: pdcursesdll.}
-proc def_shell_mode*(): cint{.extdecl, importc: "def_shell_mode", 
+proc def_shell_mode*(): cint{.extdecl, importc: "def_shell_mode",
                               dynlib: pdcursesdll.}
-proc delay_output*(a2: cint): cint{.extdecl, importc: "delay_output", 
+proc delay_output*(a2: cint): cint{.extdecl, importc: "delay_output",
                                     dynlib: pdcursesdll.}
 proc delch*(): cint{.extdecl, importc: "delch", dynlib: pdcursesdll.}
 proc deleteln*(): cint{.extdecl, importc: "deleteln", dynlib: pdcursesdll.}
-proc delscreen*(a2: ptr SCREEN){.extdecl, importc: "delscreen", 
+proc delscreen*(a2: ptr SCREEN){.extdecl, importc: "delscreen",
                                  dynlib: pdcursesdll.}
-proc delwin*(a2: ptr WINDOW): cint{.extdecl, importc: "delwin", 
+proc delwin*(a2: ptr WINDOW): cint{.extdecl, importc: "delwin",
                                     dynlib: pdcursesdll.}
 proc derwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{.
     extdecl, importc: "derwin", dynlib: pdcursesdll.}
 proc doupdate*(): cint{.extdecl, importc: "doupdate", dynlib: pdcursesdll.}
-proc dupwin*(a2: ptr WINDOW): ptr WINDOW{.extdecl, importc: "dupwin", 
+proc dupwin*(a2: ptr WINDOW): ptr WINDOW{.extdecl, importc: "dupwin",
     dynlib: pdcursesdll.}
-proc echochar*(a2: cunsignedlong): cint{.extdecl, importc: "echochar", 
+proc echochar*(a2: cunsignedlong): cint{.extdecl, importc: "echochar",
     dynlib: pdcursesdll.}
 proc echo*(): cint{.extdecl, importc: "echo", dynlib: pdcursesdll.}
 proc endwin*(): cint{.extdecl, importc: "endwin", dynlib: pdcursesdll.}
@@ -742,115 +751,115 @@ proc erase*(): cint{.extdecl, importc: "erase", dynlib: pdcursesdll.}
 proc filter*(){.extdecl, importc: "filter", dynlib: pdcursesdll.}
 proc flash*(): cint{.extdecl, importc: "flash", dynlib: pdcursesdll.}
 proc flushinp*(): cint{.extdecl, importc: "flushinp", dynlib: pdcursesdll.}
-proc getbkgd*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getbkgd", 
+proc getbkgd*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getbkgd",
     dynlib: pdcursesdll.}
-proc getnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "getnstr", 
+proc getnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "getnstr",
     dynlib: pdcursesdll.}
 proc getstr*(a2: cstring): cint{.extdecl, importc: "getstr", dynlib: pdcursesdll.}
-proc getwin*(a2: File): ptr WINDOW{.extdecl, importc: "getwin", 
+proc getwin*(a2: File): ptr WINDOW{.extdecl, importc: "getwin",
                                         dynlib: pdcursesdll.}
-proc halfdelay*(a2: cint): cint{.extdecl, importc: "halfdelay", 
+proc halfdelay*(a2: cint): cint{.extdecl, importc: "halfdelay",
                                  dynlib: pdcursesdll.}
-proc has_colors*(): cunsignedchar{.extdecl, importc: "has_colors", 
+proc has_colors*(): cunsignedchar{.extdecl, importc: "has_colors",
                                    dynlib: pdcursesdll.}
 proc has_ic*(): cunsignedchar{.extdecl, importc: "has_ic", dynlib: pdcursesdll.}
 proc has_il*(): cunsignedchar{.extdecl, importc: "has_il", dynlib: pdcursesdll.}
-proc hline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "hline", 
+proc hline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "hline",
     dynlib: pdcursesdll.}
-proc idcok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "idcok", 
+proc idcok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "idcok",
     dynlib: pdcursesdll.}
-proc idlok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok", 
+proc idlok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok",
     dynlib: pdcursesdll.}
-proc immedok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "immedok", 
+proc immedok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "immedok",
     dynlib: pdcursesdll.}
-proc inchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc inchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "inchnstr", dynlib: pdcursesdll.}
-proc inchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "inchstr", 
+proc inchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "inchstr",
     dynlib: pdcursesdll.}
 proc inch*(): cunsignedlong{.extdecl, importc: "inch", dynlib: pdcursesdll.}
-proc init_color*(a2: cshort; a3: cshort; a4: cshort; a5: cshort): cint{.extdecl, 
+proc init_color*(a2: cshort; a3: cshort; a4: cshort; a5: cshort): cint{.extdecl,
     importc: "init_color", dynlib: pdcursesdll.}
-proc init_pair*(a2: cshort; a3: cshort; a4: cshort): cint{.extdecl, 
+proc init_pair*(a2: cshort; a3: cshort; a4: cshort): cint{.extdecl,
     importc: "init_pair", dynlib: pdcursesdll.}
 proc initscr*(): ptr WINDOW{.extdecl, importc: "initscr", dynlib: pdcursesdll.}
-proc innstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innstr", 
+proc innstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innstr",
     dynlib: pdcursesdll.}
-proc insch*(a2: cunsignedlong): cint{.extdecl, importc: "insch", 
+proc insch*(a2: cunsignedlong): cint{.extdecl, importc: "insch",
                                       dynlib: pdcursesdll.}
 proc insdelln*(a2: cint): cint{.extdecl, importc: "insdelln", dynlib: pdcursesdll.}
 proc insertln*(): cint{.extdecl, importc: "insertln", dynlib: pdcursesdll.}
-proc insnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "insnstr", 
+proc insnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "insnstr",
     dynlib: pdcursesdll.}
 proc insstr*(a2: cstring): cint{.extdecl, importc: "insstr", dynlib: pdcursesdll.}
 proc instr*(a2: cstring): cint{.extdecl, importc: "instr", dynlib: pdcursesdll.}
-proc intrflush*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc intrflush*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "intrflush", dynlib: pdcursesdll.}
 proc isendwin*(): cunsignedchar{.extdecl, importc: "isendwin", dynlib: pdcursesdll.}
-proc is_linetouched*(a2: ptr WINDOW; a3: cint): cunsignedchar{.extdecl, 
+proc is_linetouched*(a2: ptr WINDOW; a3: cint): cunsignedchar{.extdecl,
     importc: "is_linetouched", dynlib: pdcursesdll.}
-proc is_wintouched*(a2: ptr WINDOW): cunsignedchar{.extdecl, 
+proc is_wintouched*(a2: ptr WINDOW): cunsignedchar{.extdecl,
     importc: "is_wintouched", dynlib: pdcursesdll.}
 proc keyname*(a2: cint): cstring{.extdecl, importc: "keyname", dynlib: pdcursesdll.}
-proc keypad*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "keypad", 
+proc keypad*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "keypad",
     dynlib: pdcursesdll.}
 proc killchar*(): char{.extdecl, importc: "killchar", dynlib: pdcursesdll.}
-proc leaveok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc leaveok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "leaveok", dynlib: pdcursesdll.}
 proc longname*(): cstring{.extdecl, importc: "longname", dynlib: pdcursesdll.}
-proc meta*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "meta", 
+proc meta*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "meta",
     dynlib: pdcursesdll.}
-proc move*(a2: cint; a3: cint): cint{.extdecl, importc: "move", 
+proc move*(a2: cint; a3: cint): cint{.extdecl, importc: "move",
                                       dynlib: pdcursesdll.}
-proc mvaddch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl, 
+proc mvaddch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl,
     importc: "mvaddch", dynlib: pdcursesdll.}
 proc mvaddchnstr*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvaddchnstr", dynlib: pdcursesdll.}
-proc mvaddchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvaddchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvaddchstr", dynlib: pdcursesdll.}
-proc mvaddnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvaddnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvaddnstr", dynlib: pdcursesdll.}
-proc mvaddstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvaddstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvaddstr", dynlib: pdcursesdll.}
-proc mvchgat*(a2: cint; a3: cint; a4: cint; a5: cunsignedlong; a6: cshort; 
+proc mvchgat*(a2: cint; a3: cint; a4: cint; a5: cunsignedlong; a6: cshort;
               a7: pointer): cint{.extdecl, importc: "mvchgat", dynlib: pdcursesdll.}
-proc mvcur*(a2: cint; a3: cint; a4: cint; a5: cint): cint{.extdecl, 
+proc mvcur*(a2: cint; a3: cint; a4: cint; a5: cint): cint{.extdecl,
     importc: "mvcur", dynlib: pdcursesdll.}
-proc mvdelch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvdelch", 
+proc mvdelch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvdelch",
     dynlib: pdcursesdll.}
-proc mvderwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc mvderwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "mvderwin", dynlib: pdcursesdll.}
-proc mvgetch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvgetch", 
+proc mvgetch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvgetch",
     dynlib: pdcursesdll.}
-proc mvgetnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvgetnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvgetnstr", dynlib: pdcursesdll.}
-proc mvgetstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvgetstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvgetstr", dynlib: pdcursesdll.}
-proc mvhline*(a2: cint; a3: cint; a4: cunsignedlong; a5: cint): cint{.extdecl, 
+proc mvhline*(a2: cint; a3: cint; a4: cunsignedlong; a5: cint): cint{.extdecl,
     importc: "mvhline", dynlib: pdcursesdll.}
-proc mvinch*(a2: cint; a3: cint): cunsignedlong{.extdecl, importc: "mvinch", 
+proc mvinch*(a2: cint; a3: cint): cunsignedlong{.extdecl, importc: "mvinch",
     dynlib: pdcursesdll.}
 proc mvinchnstr*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvinchnstr", dynlib: pdcursesdll.}
-proc mvinchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvinchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvinchstr", dynlib: pdcursesdll.}
-proc mvinnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvinnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvinnstr", dynlib: pdcursesdll.}
-proc mvinsch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl, 
+proc mvinsch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl,
     importc: "mvinsch", dynlib: pdcursesdll.}
-proc mvinsnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvinsnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvinsnstr", dynlib: pdcursesdll.}
-proc mvinsstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvinsstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvinsstr", dynlib: pdcursesdll.}
-proc mvinstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, importc: "mvinstr", 
+proc mvinstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, importc: "mvinstr",
     dynlib: pdcursesdll.}
-proc mvprintw*(a2: cint; a3: cint; a4: cstring): cint{.varargs, extdecl, 
+proc mvprintw*(a2: cint; a3: cint; a4: cstring): cint{.varargs, extdecl,
     importc: "mvprintw", dynlib: pdcursesdll.}
-proc mvscanw*(a2: cint; a3: cint; a4: cstring): cint{.varargs, extdecl, 
+proc mvscanw*(a2: cint; a3: cint; a4: cstring): cint{.varargs, extdecl,
     importc: "mvscanw", dynlib: pdcursesdll.}
-proc mvvline*(a2: cint; a3: cint; a4: cunsignedlong; a5: cint): cint{.extdecl, 
+proc mvvline*(a2: cint; a3: cint; a4: cunsignedlong; a5: cint): cint{.extdecl,
     importc: "mvvline", dynlib: pdcursesdll.}
-proc mvwaddchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                   a6: cint): cint{.extdecl, importc: "mvwaddchnstr", 
+proc mvwaddchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                   a6: cint): cint{.extdecl, importc: "mvwaddchnstr",
                                     dynlib: pdcursesdll.}
 proc mvwaddchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwaddchstr", dynlib: pdcursesdll.}
@@ -858,27 +867,27 @@ proc mvwaddch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{.
     extdecl, importc: "mvwaddch", dynlib: pdcursesdll.}
 proc mvwaddnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{.
     extdecl, importc: "mvwaddnstr", dynlib: pdcursesdll.}
-proc mvwaddstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, 
+proc mvwaddstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl,
     importc: "mvwaddstr", dynlib: pdcursesdll.}
-proc mvwchgat*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cunsignedlong; 
-               a7: cshort; a8: pointer): cint{.extdecl, importc: "mvwchgat", 
+proc mvwchgat*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cunsignedlong;
+               a7: cshort; a8: pointer): cint{.extdecl, importc: "mvwchgat",
     dynlib: pdcursesdll.}
-proc mvwdelch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc mvwdelch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "mvwdelch", dynlib: pdcursesdll.}
-proc mvwgetch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc mvwgetch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "mvwgetch", dynlib: pdcursesdll.}
 proc mvwgetnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{.
     extdecl, importc: "mvwgetnstr", dynlib: pdcursesdll.}
-proc mvwgetstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, 
+proc mvwgetstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl,
     importc: "mvwgetstr", dynlib: pdcursesdll.}
 proc mvwhline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{.
     extdecl, importc: "mvwhline", dynlib: pdcursesdll.}
-proc mvwinchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                  a6: cint): cint{.extdecl, importc: "mvwinchnstr", 
+proc mvwinchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                  a6: cint): cint{.extdecl, importc: "mvwinchnstr",
                                    dynlib: pdcursesdll.}
 proc mvwinchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwinchstr", dynlib: pdcursesdll.}
-proc mvwinch*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedlong{.extdecl, 
+proc mvwinch*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedlong{.extdecl,
     importc: "mvwinch", dynlib: pdcursesdll.}
 proc mvwinnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{.
     extdecl, importc: "mvwinnstr", dynlib: pdcursesdll.}
@@ -886,105 +895,105 @@ proc mvwinsch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{.
     extdecl, importc: "mvwinsch", dynlib: pdcursesdll.}
 proc mvwinsnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{.
     extdecl, importc: "mvwinsnstr", dynlib: pdcursesdll.}
-proc mvwinsstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, 
+proc mvwinsstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl,
     importc: "mvwinsstr", dynlib: pdcursesdll.}
-proc mvwinstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, 
+proc mvwinstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl,
     importc: "mvwinstr", dynlib: pdcursesdll.}
-proc mvwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwin", 
+proc mvwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwin",
     dynlib: pdcursesdll.}
-proc mvwprintw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, 
+proc mvwprintw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs,
     extdecl, importc: "mvwprintw", dynlib: pdcursesdll.}
-proc mvwscanw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, 
+proc mvwscanw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs,
     extdecl, importc: "mvwscanw", dynlib: pdcursesdll.}
 proc mvwvline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{.
     extdecl, importc: "mvwvline", dynlib: pdcursesdll.}
 proc napms*(a2: cint): cint{.extdecl, importc: "napms", dynlib: pdcursesdll.}
-proc newpad*(a2: cint; a3: cint): ptr WINDOW{.extdecl, importc: "newpad", 
+proc newpad*(a2: cint; a3: cint): ptr WINDOW{.extdecl, importc: "newpad",
     dynlib: pdcursesdll.}
-proc newterm*(a2: cstring; a3: File; a4: File): ptr SCREEN{.extdecl, 
+proc newterm*(a2: cstring; a3: File; a4: File): ptr SCREEN{.extdecl,
     importc: "newterm", dynlib: pdcursesdll.}
-proc newwin*(a2: cint; a3: cint; a4: cint; a5: cint): ptr WINDOW{.extdecl, 
+proc newwin*(a2: cint; a3: cint; a4: cint; a5: cint): ptr WINDOW{.extdecl,
     importc: "newwin", dynlib: pdcursesdll.}
 proc nl*(): cint{.extdecl, importc: "nl", dynlib: pdcursesdll.}
 proc nocbreak*(): cint{.extdecl, importc: "nocbreak", dynlib: pdcursesdll.}
-proc nodelay*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc nodelay*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "nodelay", dynlib: pdcursesdll.}
 proc noecho*(): cint{.extdecl, importc: "noecho", dynlib: pdcursesdll.}
 proc nonl*(): cint{.extdecl, importc: "nonl", dynlib: pdcursesdll.}
 proc noqiflush*(){.extdecl, importc: "noqiflush", dynlib: pdcursesdll.}
 proc noraw*(): cint{.extdecl, importc: "noraw", dynlib: pdcursesdll.}
-proc notimeout*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc notimeout*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "notimeout", dynlib: pdcursesdll.}
-proc overlay*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, importc: "overlay", 
+proc overlay*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, importc: "overlay",
     dynlib: pdcursesdll.}
-proc overwrite*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, 
+proc overwrite*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl,
     importc: "overwrite", dynlib: pdcursesdll.}
-proc pair_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort): cint{.extdecl, 
+proc pair_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort): cint{.extdecl,
     importc: "pair_content", dynlib: pdcursesdll.}
-proc pechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc pechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "pechochar", dynlib: pdcursesdll.}
-proc pnoutrefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint; 
-                   a7: cint; a8: cint): cint{.extdecl, importc: "pnoutrefresh", 
+proc pnoutrefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint;
+                   a7: cint; a8: cint): cint{.extdecl, importc: "pnoutrefresh",
     dynlib: pdcursesdll.}
-proc prefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint; a7: cint; 
+proc prefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint; a7: cint;
                a8: cint): cint{.extdecl, importc: "prefresh", dynlib: pdcursesdll.}
-proc printw*(a2: cstring): cint{.varargs, extdecl, importc: "printw", 
+proc printw*(a2: cstring): cint{.varargs, extdecl, importc: "printw",
                                  dynlib: pdcursesdll.}
-proc putwin*(a2: ptr WINDOW; a3: File): cint{.extdecl, importc: "putwin", 
+proc putwin*(a2: ptr WINDOW; a3: File): cint{.extdecl, importc: "putwin",
     dynlib: pdcursesdll.}
 proc qiflush*(){.extdecl, importc: "qiflush", dynlib: pdcursesdll.}
 proc raw*(): cint{.extdecl, importc: "raw", dynlib: pdcursesdll.}
-proc redrawwin*(a2: ptr WINDOW): cint{.extdecl, importc: "redrawwin", 
+proc redrawwin*(a2: ptr WINDOW): cint{.extdecl, importc: "redrawwin",
                                        dynlib: pdcursesdll.}
 proc refresh*(): cint{.extdecl, importc: "refresh", dynlib: pdcursesdll.}
-proc reset_prog_mode*(): cint{.extdecl, importc: "reset_prog_mode", 
+proc reset_prog_mode*(): cint{.extdecl, importc: "reset_prog_mode",
                                dynlib: pdcursesdll.}
-proc reset_shell_mode*(): cint{.extdecl, importc: "reset_shell_mode", 
+proc reset_shell_mode*(): cint{.extdecl, importc: "reset_shell_mode",
                                 dynlib: pdcursesdll.}
 proc resetty*(): cint{.extdecl, importc: "resetty", dynlib: pdcursesdll.}
 #int     ripoffline(int, int (*)(WINDOW *, int));
 proc savetty*(): cint{.extdecl, importc: "savetty", dynlib: pdcursesdll.}
-proc scanw*(a2: cstring): cint{.varargs, extdecl, importc: "scanw", 
+proc scanw*(a2: cstring): cint{.varargs, extdecl, importc: "scanw",
                                 dynlib: pdcursesdll.}
-proc scr_dump*(a2: cstring): cint{.extdecl, importc: "scr_dump", 
+proc scr_dump*(a2: cstring): cint{.extdecl, importc: "scr_dump",
                                    dynlib: pdcursesdll.}
-proc scr_init*(a2: cstring): cint{.extdecl, importc: "scr_init", 
+proc scr_init*(a2: cstring): cint{.extdecl, importc: "scr_init",
                                    dynlib: pdcursesdll.}
-proc scr_restore*(a2: cstring): cint{.extdecl, importc: "scr_restore", 
+proc scr_restore*(a2: cstring): cint{.extdecl, importc: "scr_restore",
                                       dynlib: pdcursesdll.}
 proc scr_set*(a2: cstring): cint{.extdecl, importc: "scr_set", dynlib: pdcursesdll.}
 proc scrl*(a2: cint): cint{.extdecl, importc: "scrl", dynlib: pdcursesdll.}
-proc scroll*(a2: ptr WINDOW): cint{.extdecl, importc: "scroll", 
+proc scroll*(a2: ptr WINDOW): cint{.extdecl, importc: "scroll",
                                     dynlib: pdcursesdll.}
-proc scrollok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, 
+proc scrollok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl,
     importc: "scrollok", dynlib: pdcursesdll.}
-proc set_term*(a2: ptr SCREEN): ptr SCREEN{.extdecl, importc: "set_term", 
+proc set_term*(a2: ptr SCREEN): ptr SCREEN{.extdecl, importc: "set_term",
     dynlib: pdcursesdll.}
-proc setscrreg*(a2: cint; a3: cint): cint{.extdecl, importc: "setscrreg", 
+proc setscrreg*(a2: cint; a3: cint): cint{.extdecl, importc: "setscrreg",
     dynlib: pdcursesdll.}
-proc slk_attroff*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attroff", 
+proc slk_attroff*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attroff",
     dynlib: pdcursesdll.}
-proc slk_attr_off*(a2: cunsignedlong; a3: pointer): cint{.extdecl, 
+proc slk_attr_off*(a2: cunsignedlong; a3: pointer): cint{.extdecl,
     importc: "slk_attr_off", dynlib: pdcursesdll.}
-proc slk_attron*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attron", 
+proc slk_attron*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attron",
     dynlib: pdcursesdll.}
-proc slk_attr_on*(a2: cunsignedlong; a3: pointer): cint{.extdecl, 
+proc slk_attr_on*(a2: cunsignedlong; a3: pointer): cint{.extdecl,
     importc: "slk_attr_on", dynlib: pdcursesdll.}
-proc slk_attrset*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attrset", 
+proc slk_attrset*(a2: cunsignedlong): cint{.extdecl, importc: "slk_attrset",
     dynlib: pdcursesdll.}
-proc slk_attr_set*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl, 
+proc slk_attr_set*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl,
     importc: "slk_attr_set", dynlib: pdcursesdll.}
 proc slk_clear*(): cint{.extdecl, importc: "slk_clear", dynlib: pdcursesdll.}
-proc slk_color*(a2: cshort): cint{.extdecl, importc: "slk_color", 
+proc slk_color*(a2: cshort): cint{.extdecl, importc: "slk_color",
                                    dynlib: pdcursesdll.}
 proc slk_init*(a2: cint): cint{.extdecl, importc: "slk_init", dynlib: pdcursesdll.}
-proc slk_label*(a2: cint): cstring{.extdecl, importc: "slk_label", 
+proc slk_label*(a2: cint): cstring{.extdecl, importc: "slk_label",
                                     dynlib: pdcursesdll.}
-proc slk_noutrefresh*(): cint{.extdecl, importc: "slk_noutrefresh", 
+proc slk_noutrefresh*(): cint{.extdecl, importc: "slk_noutrefresh",
                                dynlib: pdcursesdll.}
 proc slk_refresh*(): cint{.extdecl, importc: "slk_refresh", dynlib: pdcursesdll.}
 proc slk_restore*(): cint{.extdecl, importc: "slk_restore", dynlib: pdcursesdll.}
-proc slk_set*(a2: cint; a3: cstring; a4: cint): cint{.extdecl, importc: "slk_set", 
+proc slk_set*(a2: cint; a3: cstring; a4: cint): cint{.extdecl, importc: "slk_set",
     dynlib: pdcursesdll.}
 proc slk_touch*(): cint{.extdecl, importc: "slk_touch", dynlib: pdcursesdll.}
 proc standend*(): cint{.extdecl, importc: "standend", dynlib: pdcursesdll.}
@@ -994,30 +1003,30 @@ proc subpad*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW
     extdecl, importc: "subpad", dynlib: pdcursesdll.}
 proc subwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{.
     extdecl, importc: "subwin", dynlib: pdcursesdll.}
-proc syncok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "syncok", 
+proc syncok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "syncok",
     dynlib: pdcursesdll.}
-proc termattrs*(): cunsignedlong{.extdecl, importc: "termattrs", 
+proc termattrs*(): cunsignedlong{.extdecl, importc: "termattrs",
                                   dynlib: pdcursesdll.}
-proc termattrs2*(): cunsignedlong{.extdecl, importc: "term_attrs", 
+proc termattrs2*(): cunsignedlong{.extdecl, importc: "term_attrs",
                                    dynlib: pdcursesdll.}
 proc termname*(): cstring{.extdecl, importc: "termname", dynlib: pdcursesdll.}
 proc timeout*(a2: cint){.extdecl, importc: "timeout", dynlib: pdcursesdll.}
-proc touchline*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc touchline*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "touchline", dynlib: pdcursesdll.}
-proc touchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "touchwin", 
+proc touchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "touchwin",
                                       dynlib: pdcursesdll.}
-proc typeahead*(a2: cint): cint{.extdecl, importc: "typeahead", 
+proc typeahead*(a2: cint): cint{.extdecl, importc: "typeahead",
                                  dynlib: pdcursesdll.}
-proc untouchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "untouchwin", 
+proc untouchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "untouchwin",
                                         dynlib: pdcursesdll.}
 proc use_env*(a2: cunsignedchar){.extdecl, importc: "use_env", dynlib: pdcursesdll.}
-proc vidattr*(a2: cunsignedlong): cint{.extdecl, importc: "vidattr", 
+proc vidattr*(a2: cunsignedlong): cint{.extdecl, importc: "vidattr",
                                         dynlib: pdcursesdll.}
-proc vid_attr*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl, 
+proc vid_attr*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl,
     importc: "vid_attr", dynlib: pdcursesdll.}
 #int     vidputs(chtype, int (*)(int));
 #int     vid_puts(attr_t, short, void *, int (*)(int));
-proc vline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "vline", 
+proc vline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "vline",
     dynlib: pdcursesdll.}
 proc vwprintw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs,
     importc: "vw_printw", dynlib: pdcursesdll.}
@@ -1027,203 +1036,203 @@ proc vwscanw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs,
     importc: "vw_scanw", dynlib: pdcursesdll.}
 proc vwscanw2*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs,
     importc: "vwscanw", dynlib: pdcursesdll.}
-proc waddchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, 
+proc waddchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl,
     importc: "waddchnstr", dynlib: pdcursesdll.}
-proc waddchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc waddchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "waddchstr", dynlib: pdcursesdll.}
-proc waddch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch", 
+proc waddch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch",
     dynlib: pdcursesdll.}
-proc waddnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc waddnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "waddnstr", dynlib: pdcursesdll.}
-proc waddstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddstr", 
+proc waddstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddstr",
     dynlib: pdcursesdll.}
-proc wattroff*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc wattroff*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "wattroff", dynlib: pdcursesdll.}
-proc wattron*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc wattron*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "wattron", dynlib: pdcursesdll.}
-proc wattrset*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc wattrset*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "wattrset", dynlib: pdcursesdll.}
-proc wattr_get*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cshort; 
-                a5: pointer): cint{.extdecl, importc: "wattr_get", 
+proc wattr_get*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cshort;
+                a5: pointer): cint{.extdecl, importc: "wattr_get",
                                     dynlib: pdcursesdll.}
-proc wattr_off*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, 
+proc wattr_off*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl,
     importc: "wattr_off", dynlib: pdcursesdll.}
-proc wattr_on*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, 
+proc wattr_on*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl,
     importc: "wattr_on", dynlib: pdcursesdll.}
 proc wattr_set*(a2: ptr WINDOW; a3: cunsignedlong; a4: cshort; a5: pointer): cint{.
     extdecl, importc: "wattr_set", dynlib: pdcursesdll.}
-proc wbkgdset*(a2: ptr WINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset", 
+proc wbkgdset*(a2: ptr WINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset",
     dynlib: pdcursesdll.}
-proc wbkgd*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd", 
+proc wbkgd*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd",
     dynlib: pdcursesdll.}
-proc wborder*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong; 
-              a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong; 
+proc wborder*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong;
+              a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong;
               a8: cunsignedlong; a9: cunsignedlong; a10: cunsignedlong): cint{.
     extdecl, importc: "wborder", dynlib: pdcursesdll.}
-proc wchgat*(a2: ptr WINDOW; a3: cint; a4: cunsignedlong; a5: cshort; 
+proc wchgat*(a2: ptr WINDOW; a3: cint; a4: cunsignedlong; a5: cshort;
              a6: pointer): cint{.extdecl, importc: "wchgat", dynlib: pdcursesdll.}
-proc wclear*(a2: ptr WINDOW): cint{.extdecl, importc: "wclear", 
+proc wclear*(a2: ptr WINDOW): cint{.extdecl, importc: "wclear",
                                     dynlib: pdcursesdll.}
-proc wclrtobot*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtobot", 
+proc wclrtobot*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtobot",
                                        dynlib: pdcursesdll.}
-proc wclrtoeol*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtoeol", 
+proc wclrtoeol*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtoeol",
                                        dynlib: pdcursesdll.}
-proc wcolor_set*(a2: ptr WINDOW; a3: cshort; a4: pointer): cint{.extdecl, 
+proc wcolor_set*(a2: ptr WINDOW; a3: cshort; a4: pointer): cint{.extdecl,
     importc: "wcolor_set", dynlib: pdcursesdll.}
-proc wcursyncup*(a2: ptr WINDOW){.extdecl, importc: "wcursyncup", 
+proc wcursyncup*(a2: ptr WINDOW){.extdecl, importc: "wcursyncup",
                                   dynlib: pdcursesdll.}
-proc wdelch*(a2: ptr WINDOW): cint{.extdecl, importc: "wdelch", 
+proc wdelch*(a2: ptr WINDOW): cint{.extdecl, importc: "wdelch",
                                     dynlib: pdcursesdll.}
-proc wdeleteln*(a2: ptr WINDOW): cint{.extdecl, importc: "wdeleteln", 
+proc wdeleteln*(a2: ptr WINDOW): cint{.extdecl, importc: "wdeleteln",
                                        dynlib: pdcursesdll.}
-proc wechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc wechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "wechochar", dynlib: pdcursesdll.}
-proc werase*(a2: ptr WINDOW): cint{.extdecl, importc: "werase", 
+proc werase*(a2: ptr WINDOW): cint{.extdecl, importc: "werase",
                                     dynlib: pdcursesdll.}
-proc wgetch*(a2: ptr WINDOW): cint{.extdecl, importc: "wgetch", 
+proc wgetch*(a2: ptr WINDOW): cint{.extdecl, importc: "wgetch",
                                     dynlib: pdcursesdll.}
-proc wgetnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc wgetnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "wgetnstr", dynlib: pdcursesdll.}
-proc wgetstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr", 
+proc wgetstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr",
     dynlib: pdcursesdll.}
-proc whline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, 
+proc whline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl,
     importc: "whline", dynlib: pdcursesdll.}
-proc winchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, 
+proc winchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl,
     importc: "winchnstr", dynlib: pdcursesdll.}
-proc winchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc winchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "winchstr", dynlib: pdcursesdll.}
-proc winch*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "winch", 
+proc winch*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "winch",
     dynlib: pdcursesdll.}
-proc winnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc winnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "winnstr", dynlib: pdcursesdll.}
-proc winsch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch", 
+proc winsch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch",
     dynlib: pdcursesdll.}
-proc winsdelln*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "winsdelln", 
+proc winsdelln*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "winsdelln",
     dynlib: pdcursesdll.}
-proc winsertln*(a2: ptr WINDOW): cint{.extdecl, importc: "winsertln", 
+proc winsertln*(a2: ptr WINDOW): cint{.extdecl, importc: "winsertln",
                                        dynlib: pdcursesdll.}
-proc winsnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc winsnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "winsnstr", dynlib: pdcursesdll.}
-proc winsstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winsstr", 
+proc winsstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winsstr",
     dynlib: pdcursesdll.}
-proc winstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winstr", 
+proc winstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winstr",
     dynlib: pdcursesdll.}
-proc wmove*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wmove", 
+proc wmove*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wmove",
     dynlib: pdcursesdll.}
-proc wnoutrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wnoutrefresh", 
+proc wnoutrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wnoutrefresh",
     dynlib: pdcursesdll.}
-proc wprintw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, 
+proc wprintw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl,
     importc: "wprintw", dynlib: pdcursesdll.}
-proc wredrawln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc wredrawln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "wredrawln", dynlib: pdcursesdll.}
-proc wrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wrefresh", 
+proc wrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wrefresh",
                                       dynlib: pdcursesdll.}
-proc wscanw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, 
+proc wscanw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl,
     importc: "wscanw", dynlib: pdcursesdll.}
-proc wscrl*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "wscrl", 
+proc wscrl*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "wscrl",
     dynlib: pdcursesdll.}
-proc wsetscrreg*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc wsetscrreg*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "wsetscrreg", dynlib: pdcursesdll.}
-proc wstandend*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandend", 
+proc wstandend*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandend",
                                        dynlib: pdcursesdll.}
-proc wstandout*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandout", 
+proc wstandout*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandout",
                                        dynlib: pdcursesdll.}
-proc wsyncdown*(a2: ptr WINDOW){.extdecl, importc: "wsyncdown", 
+proc wsyncdown*(a2: ptr WINDOW){.extdecl, importc: "wsyncdown",
                                  dynlib: pdcursesdll.}
 proc wsyncup*(a2: ptr WINDOW){.extdecl, importc: "wsyncup", dynlib: pdcursesdll.}
-proc wtimeout*(a2: ptr WINDOW; a3: cint){.extdecl, importc: "wtimeout", 
+proc wtimeout*(a2: ptr WINDOW; a3: cint){.extdecl, importc: "wtimeout",
     dynlib: pdcursesdll.}
-proc wtouchln*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint): cint{.extdecl, 
+proc wtouchln*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint): cint{.extdecl,
     importc: "wtouchln", dynlib: pdcursesdll.}
-proc wvline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, 
+proc wvline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl,
     importc: "wvline", dynlib: pdcursesdll.}
-proc addnwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "addnwstr", 
+proc addnwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "addnwstr",
     dynlib: pdcursesdll.}
-proc addwstr*(a2: cstring): cint{.extdecl, importc: "addwstr", 
+proc addwstr*(a2: cstring): cint{.extdecl, importc: "addwstr",
                                       dynlib: pdcursesdll.}
-proc add_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "add_wch", 
+proc add_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "add_wch",
     dynlib: pdcursesdll.}
-proc add_wchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc add_wchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "add_wchnstr", dynlib: pdcursesdll.}
-proc add_wchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "add_wchstr", 
+proc add_wchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "add_wchstr",
     dynlib: pdcursesdll.}
-proc border_set*(a2: ptr cunsignedlong; a3: ptr cunsignedlong; 
-                 a4: ptr cunsignedlong; a5: ptr cunsignedlong; 
-                 a6: ptr cunsignedlong; a7: ptr cunsignedlong; 
-                 a8: ptr cunsignedlong; a9: ptr cunsignedlong): cint{.extdecl, 
+proc border_set*(a2: ptr cunsignedlong; a3: ptr cunsignedlong;
+                 a4: ptr cunsignedlong; a5: ptr cunsignedlong;
+                 a6: ptr cunsignedlong; a7: ptr cunsignedlong;
+                 a8: ptr cunsignedlong; a9: ptr cunsignedlong): cint{.extdecl,
     importc: "border_set", dynlib: pdcursesdll.}
 proc box_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong): cint{.
     extdecl, importc: "box_set", dynlib: pdcursesdll.}
-proc echo_wchar*(a2: ptr cunsignedlong): cint{.extdecl, importc: "echo_wchar", 
+proc echo_wchar*(a2: ptr cunsignedlong): cint{.extdecl, importc: "echo_wchar",
     dynlib: pdcursesdll.}
-proc erasewchar*(a2: cstring): cint{.extdecl, importc: "erasewchar", 
+proc erasewchar*(a2: cstring): cint{.extdecl, importc: "erasewchar",
     dynlib: pdcursesdll.}
-proc getbkgrnd*(a2: ptr cunsignedlong): cint{.extdecl, importc: "getbkgrnd", 
+proc getbkgrnd*(a2: ptr cunsignedlong): cint{.extdecl, importc: "getbkgrnd",
     dynlib: pdcursesdll.}
-proc getcchar*(a2: ptr cunsignedlong; a3: cstring; a4: ptr cunsignedlong; 
-               a5: ptr cshort; a6: pointer): cint{.extdecl, importc: "getcchar", 
+proc getcchar*(a2: ptr cunsignedlong; a3: cstring; a4: ptr cunsignedlong;
+               a5: ptr cshort; a6: pointer): cint{.extdecl, importc: "getcchar",
     dynlib: pdcursesdll.}
-proc getn_wstr*(a2: ptr cint; a3: cint): cint{.extdecl, importc: "getn_wstr", 
+proc getn_wstr*(a2: ptr cint; a3: cint): cint{.extdecl, importc: "getn_wstr",
     dynlib: pdcursesdll.}
-proc get_wch*(a2: ptr cint): cint{.extdecl, importc: "get_wch", 
+proc get_wch*(a2: ptr cint): cint{.extdecl, importc: "get_wch",
                                      dynlib: pdcursesdll.}
-proc get_wstr*(a2: ptr cint): cint{.extdecl, importc: "get_wstr", 
+proc get_wstr*(a2: ptr cint): cint{.extdecl, importc: "get_wstr",
                                       dynlib: pdcursesdll.}
-proc hline_set*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc hline_set*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "hline_set", dynlib: pdcursesdll.}
-proc innwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innwstr", 
+proc innwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innwstr",
     dynlib: pdcursesdll.}
-proc ins_nwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "ins_nwstr", 
+proc ins_nwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "ins_nwstr",
     dynlib: pdcursesdll.}
-proc ins_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "ins_wch", 
+proc ins_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "ins_wch",
     dynlib: pdcursesdll.}
-proc ins_wstr*(a2: cstring): cint{.extdecl, importc: "ins_wstr", 
+proc ins_wstr*(a2: cstring): cint{.extdecl, importc: "ins_wstr",
                                        dynlib: pdcursesdll.}
-proc inwstr*(a2: cstring): cint{.extdecl, importc: "inwstr", 
+proc inwstr*(a2: cstring): cint{.extdecl, importc: "inwstr",
                                      dynlib: pdcursesdll.}
-proc in_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "in_wch", 
+proc in_wch*(a2: ptr cunsignedlong): cint{.extdecl, importc: "in_wch",
     dynlib: pdcursesdll.}
-proc in_wchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc in_wchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "in_wchnstr", dynlib: pdcursesdll.}
-proc in_wchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "in_wchstr", 
+proc in_wchstr*(a2: ptr cunsignedlong): cint{.extdecl, importc: "in_wchstr",
     dynlib: pdcursesdll.}
-proc key_name*(a2: char): cstring{.extdecl, importc: "key_name", 
+proc key_name*(a2: char): cstring{.extdecl, importc: "key_name",
                                       dynlib: pdcursesdll.}
-proc killwchar*(a2: cstring): cint{.extdecl, importc: "killwchar", 
+proc killwchar*(a2: cstring): cint{.extdecl, importc: "killwchar",
                                         dynlib: pdcursesdll.}
-proc mvaddnwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvaddnwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvaddnwstr", dynlib: pdcursesdll.}
-proc mvaddwstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvaddwstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvaddwstr", dynlib: pdcursesdll.}
-proc mvadd_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvadd_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvadd_wch", dynlib: pdcursesdll.}
 proc mvadd_wchnstr*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvadd_wchnstr", dynlib: pdcursesdll.}
-proc mvadd_wchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvadd_wchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvadd_wchstr", dynlib: pdcursesdll.}
-proc mvgetn_wstr*(a2: cint; a3: cint; a4: ptr cint; a5: cint): cint{.extdecl, 
+proc mvgetn_wstr*(a2: cint; a3: cint; a4: ptr cint; a5: cint): cint{.extdecl,
     importc: "mvgetn_wstr", dynlib: pdcursesdll.}
-proc mvget_wch*(a2: cint; a3: cint; a4: ptr cint): cint{.extdecl, 
+proc mvget_wch*(a2: cint; a3: cint; a4: ptr cint): cint{.extdecl,
     importc: "mvget_wch", dynlib: pdcursesdll.}
-proc mvget_wstr*(a2: cint; a3: cint; a4: ptr cint): cint{.extdecl, 
+proc mvget_wstr*(a2: cint; a3: cint; a4: ptr cint): cint{.extdecl,
     importc: "mvget_wstr", dynlib: pdcursesdll.}
 proc mvhline_set*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvhline_set", dynlib: pdcursesdll.}
-proc mvinnwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvinnwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvinnwstr", dynlib: pdcursesdll.}
-proc mvins_nwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl, 
+proc mvins_nwstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint{.extdecl,
     importc: "mvins_nwstr", dynlib: pdcursesdll.}
-proc mvins_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvins_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvins_wch", dynlib: pdcursesdll.}
-proc mvins_wstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvins_wstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvins_wstr", dynlib: pdcursesdll.}
-proc mvinwstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl, 
+proc mvinwstr*(a2: cint; a3: cint; a4: cstring): cint{.extdecl,
     importc: "mvinwstr", dynlib: pdcursesdll.}
-proc mvin_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvin_wch*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvin_wch", dynlib: pdcursesdll.}
 proc mvin_wchnstr*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvin_wchnstr", dynlib: pdcursesdll.}
-proc mvin_wchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, 
+proc mvin_wchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl,
     importc: "mvin_wchstr", dynlib: pdcursesdll.}
 proc mvvline_set*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{.
     extdecl, importc: "mvvline_set", dynlib: pdcursesdll.}
@@ -1233,8 +1242,8 @@ proc mvwaddwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.
     extdecl, importc: "mvwaddwstr", dynlib: pdcursesdll.}
 proc mvwadd_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwadd_wch", dynlib: pdcursesdll.}
-proc mvwadd_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                     a6: cint): cint{.extdecl, importc: "mvwadd_wchnstr", 
+proc mvwadd_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                     a6: cint): cint{.extdecl, importc: "mvwadd_wchnstr",
                                       dynlib: pdcursesdll.}
 proc mvwadd_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwadd_wchstr", dynlib: pdcursesdll.}
@@ -1244,8 +1253,8 @@ proc mvwget_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint): cint{.
     extdecl, importc: "mvwget_wch", dynlib: pdcursesdll.}
 proc mvwget_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint): cint{.
     extdecl, importc: "mvwget_wstr", dynlib: pdcursesdll.}
-proc mvwhline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                   a6: cint): cint{.extdecl, importc: "mvwhline_set", 
+proc mvwhline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                   a6: cint): cint{.extdecl, importc: "mvwhline_set",
                                     dynlib: pdcursesdll.}
 proc mvwinnwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{.
     extdecl, importc: "mvwinnwstr", dynlib: pdcursesdll.}
@@ -1257,99 +1266,99 @@ proc mvwins_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.
     extdecl, importc: "mvwins_wstr", dynlib: pdcursesdll.}
 proc mvwin_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwin_wch", dynlib: pdcursesdll.}
-proc mvwin_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                    a6: cint): cint{.extdecl, importc: "mvwin_wchnstr", 
+proc mvwin_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                    a6: cint): cint{.extdecl, importc: "mvwin_wchnstr",
                                      dynlib: pdcursesdll.}
 proc mvwin_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{.
     extdecl, importc: "mvwin_wchstr", dynlib: pdcursesdll.}
 proc mvwinwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.
     extdecl, importc: "mvwinwstr", dynlib: pdcursesdll.}
-proc mvwvline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; 
-                   a6: cint): cint{.extdecl, importc: "mvwvline_set", 
+proc mvwvline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong;
+                   a6: cint): cint{.extdecl, importc: "mvwvline_set",
                                     dynlib: pdcursesdll.}
-proc pecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc pecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "pecho_wchar", dynlib: pdcursesdll.}
-proc setcchar*(a2: ptr cunsignedlong; a3: cstring; a4: cunsignedlong; 
-               a5: cshort; a6: pointer): cint{.extdecl, importc: "setcchar", 
+proc setcchar*(a2: ptr cunsignedlong; a3: cstring; a4: cunsignedlong;
+               a5: cshort; a6: pointer): cint{.extdecl, importc: "setcchar",
     dynlib: pdcursesdll.}
-proc slk_wset*(a2: cint; a3: cstring; a4: cint): cint{.extdecl, 
+proc slk_wset*(a2: cint; a3: cstring; a4: cint): cint{.extdecl,
     importc: "slk_wset", dynlib: pdcursesdll.}
-proc unget_wch*(a2: char): cint{.extdecl, importc: "unget_wch", 
+proc unget_wch*(a2: char): cint{.extdecl, importc: "unget_wch",
                                     dynlib: pdcursesdll.}
-proc vline_set*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, 
+proc vline_set*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl,
     importc: "vline_set", dynlib: pdcursesdll.}
-proc waddnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc waddnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "waddnwstr", dynlib: pdcursesdll.}
-proc waddwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, 
+proc waddwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl,
     importc: "waddwstr", dynlib: pdcursesdll.}
-proc wadd_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wadd_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wadd_wch", dynlib: pdcursesdll.}
 proc wadd_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.
     extdecl, importc: "wadd_wchnstr", dynlib: pdcursesdll.}
-proc wadd_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wadd_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wadd_wchstr", dynlib: pdcursesdll.}
-proc wbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wbkgrnd", dynlib: pdcursesdll.}
-proc wbkgrndset*(a2: ptr WINDOW; a3: ptr cunsignedlong){.extdecl, 
+proc wbkgrndset*(a2: ptr WINDOW; a3: ptr cunsignedlong){.extdecl,
     importc: "wbkgrndset", dynlib: pdcursesdll.}
-proc wborder_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong; 
-                  a5: ptr cunsignedlong; a6: ptr cunsignedlong; 
-                  a7: ptr cunsignedlong; a8: ptr cunsignedlong; 
-                  a9: ptr cunsignedlong; a10: ptr cunsignedlong): cint{.extdecl, 
+proc wborder_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong;
+                  a5: ptr cunsignedlong; a6: ptr cunsignedlong;
+                  a7: ptr cunsignedlong; a8: ptr cunsignedlong;
+                  a9: ptr cunsignedlong; a10: ptr cunsignedlong): cint{.extdecl,
     importc: "wborder_set", dynlib: pdcursesdll.}
-proc wecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wecho_wchar", dynlib: pdcursesdll.}
-proc wgetbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wgetbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wgetbkgrnd", dynlib: pdcursesdll.}
-proc wgetn_wstr*(a2: ptr WINDOW; a3: ptr cint; a4: cint): cint{.extdecl, 
+proc wgetn_wstr*(a2: ptr WINDOW; a3: ptr cint; a4: cint): cint{.extdecl,
     importc: "wgetn_wstr", dynlib: pdcursesdll.}
-proc wget_wch*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl, 
+proc wget_wch*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl,
     importc: "wget_wch", dynlib: pdcursesdll.}
-proc wget_wstr*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl, 
+proc wget_wstr*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl,
     importc: "wget_wstr", dynlib: pdcursesdll.}
-proc whline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, 
+proc whline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl,
     importc: "whline_set", dynlib: pdcursesdll.}
-proc winnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc winnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "winnwstr", dynlib: pdcursesdll.}
-proc wins_nwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, 
+proc wins_nwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl,
     importc: "wins_nwstr", dynlib: pdcursesdll.}
-proc wins_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc wins_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "wins_wch", dynlib: pdcursesdll.}
-proc wins_wstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, 
+proc wins_wstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl,
     importc: "wins_wstr", dynlib: pdcursesdll.}
-proc winwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winwstr", 
+proc winwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winwstr",
     dynlib: pdcursesdll.}
-proc win_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc win_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "win_wch", dynlib: pdcursesdll.}
-proc win_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, 
+proc win_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl,
     importc: "win_wchnstr", dynlib: pdcursesdll.}
-proc win_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, 
+proc win_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl,
     importc: "win_wchstr", dynlib: pdcursesdll.}
-proc wunctrl*(a2: ptr cunsignedlong): cstring{.extdecl, importc: "wunctrl", 
+proc wunctrl*(a2: ptr cunsignedlong): cstring{.extdecl, importc: "wunctrl",
     dynlib: pdcursesdll.}
-proc wvline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, 
+proc wvline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl,
     importc: "wvline_set", dynlib: pdcursesdll.}
-proc getattrs*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getattrs", 
+proc getattrs*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getattrs",
     dynlib: pdcursesdll.}
-proc getbegx*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegx", 
+proc getbegx*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegx",
                                      dynlib: pdcursesdll.}
-proc getbegy*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegy", 
+proc getbegy*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegy",
                                      dynlib: pdcursesdll.}
-proc getmaxx*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxx", 
+proc getmaxx*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxx",
                                      dynlib: pdcursesdll.}
-proc getmaxy*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxy", 
+proc getmaxy*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxy",
                                      dynlib: pdcursesdll.}
-proc getparx*(a2: ptr WINDOW): cint{.extdecl, importc: "getparx", 
+proc getparx*(a2: ptr WINDOW): cint{.extdecl, importc: "getparx",
                                      dynlib: pdcursesdll.}
-proc getpary*(a2: ptr WINDOW): cint{.extdecl, importc: "getpary", 
+proc getpary*(a2: ptr WINDOW): cint{.extdecl, importc: "getpary",
                                      dynlib: pdcursesdll.}
-proc getcurx*(a2: ptr WINDOW): cint{.extdecl, importc: "getcurx", 
+proc getcurx*(a2: ptr WINDOW): cint{.extdecl, importc: "getcurx",
                                      dynlib: pdcursesdll.}
-proc getcury*(a2: ptr WINDOW): cint{.extdecl, importc: "getcury", 
+proc getcury*(a2: ptr WINDOW): cint{.extdecl, importc: "getcury",
                                      dynlib: pdcursesdll.}
 proc traceoff*(){.extdecl, importc: "traceoff", dynlib: pdcursesdll.}
 proc traceon*(){.extdecl, importc: "traceon", dynlib: pdcursesdll.}
-proc unctrl*(a2: cunsignedlong): cstring{.extdecl, importc: "unctrl", 
+proc unctrl*(a2: cunsignedlong): cstring{.extdecl, importc: "unctrl",
     dynlib: pdcursesdll.}
 proc crmode*(): cint{.extdecl, importc: "crmode", dynlib: pdcursesdll.}
 proc nocrmode*(): cint{.extdecl, importc: "nocrmode", dynlib: pdcursesdll.}
@@ -1357,156 +1366,156 @@ proc draino*(a2: cint): cint{.extdecl, importc: "draino", dynlib: pdcursesdll.}
 proc resetterm*(): cint{.extdecl, importc: "resetterm", dynlib: pdcursesdll.}
 proc fixterm*(): cint{.extdecl, importc: "fixterm", dynlib: pdcursesdll.}
 proc saveterm*(): cint{.extdecl, importc: "saveterm", dynlib: pdcursesdll.}
-proc setsyx*(a2: cint; a3: cint): cint{.extdecl, importc: "setsyx", 
+proc setsyx*(a2: cint; a3: cint): cint{.extdecl, importc: "setsyx",
                                         dynlib: pdcursesdll.}
-proc mouse_set*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_set", 
+proc mouse_set*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_set",
     dynlib: pdcursesdll.}
-proc mouse_on*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_on", 
+proc mouse_on*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_on",
     dynlib: pdcursesdll.}
-proc mouse_off*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_off", 
+proc mouse_off*(a2: cunsignedlong): cint{.extdecl, importc: "mouse_off",
     dynlib: pdcursesdll.}
-proc request_mouse_pos*(): cint{.extdecl, importc: "request_mouse_pos", 
+proc request_mouse_pos*(): cint{.extdecl, importc: "request_mouse_pos",
                                  dynlib: pdcursesdll.}
-proc map_button*(a2: cunsignedlong): cint{.extdecl, importc: "map_button", 
+proc map_button*(a2: cunsignedlong): cint{.extdecl, importc: "map_button",
     dynlib: pdcursesdll.}
-proc wmouse_position*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint){.extdecl, 
+proc wmouse_position*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint){.extdecl,
     importc: "wmouse_position", dynlib: pdcursesdll.}
 proc getmouse*(): cunsignedlong{.extdecl, importc: "getmouse", dynlib: pdcursesdll.}
 proc getbmap*(): cunsignedlong{.extdecl, importc: "getbmap", dynlib: pdcursesdll.}
-proc assume_default_colors*(a2: cint; a3: cint): cint{.extdecl, 
+proc assume_default_colors*(a2: cint; a3: cint): cint{.extdecl,
     importc: "assume_default_colors", dynlib: pdcursesdll.}
-proc curses_version*(): cstring{.extdecl, importc: "curses_version", 
+proc curses_version*(): cstring{.extdecl, importc: "curses_version",
                                  dynlib: pdcursesdll.}
-proc has_key*(a2: cint): cunsignedchar{.extdecl, importc: "has_key", 
+proc has_key*(a2: cint): cunsignedchar{.extdecl, importc: "has_key",
                                         dynlib: pdcursesdll.}
-proc use_default_colors*(): cint{.extdecl, importc: "use_default_colors", 
+proc use_default_colors*(): cint{.extdecl, importc: "use_default_colors",
                                   dynlib: pdcursesdll.}
-proc wresize*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc wresize*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "wresize", dynlib: pdcursesdll.}
-proc mouseinterval*(a2: cint): cint{.extdecl, importc: "mouseinterval", 
+proc mouseinterval*(a2: cint): cint{.extdecl, importc: "mouseinterval",
                                      dynlib: pdcursesdll.}
-proc mousemask*(a2: cunsignedlong; a3: ptr cunsignedlong): cunsignedlong{.extdecl, 
+proc mousemask*(a2: cunsignedlong; a3: ptr cunsignedlong): cunsignedlong{.extdecl,
     importc: "mousemask", dynlib: pdcursesdll.}
 proc mouse_trafo*(a2: ptr cint; a3: ptr cint; a4: cunsignedchar): cunsignedchar{.
     extdecl, importc: "mouse_trafo", dynlib: pdcursesdll.}
-proc nc_getmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "nc_getmouse", 
+proc nc_getmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "nc_getmouse",
     dynlib: pdcursesdll.}
-proc ungetmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "ungetmouse", 
+proc ungetmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "ungetmouse",
                                         dynlib: pdcursesdll.}
-proc wenclose*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedchar{.extdecl, 
+proc wenclose*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedchar{.extdecl,
     importc: "wenclose", dynlib: pdcursesdll.}
 proc wmouse_trafo*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint; a5: cunsignedchar): cunsignedchar{.
     extdecl, importc: "wmouse_trafo", dynlib: pdcursesdll.}
-proc addrawch*(a2: cunsignedlong): cint{.extdecl, importc: "addrawch", 
+proc addrawch*(a2: cunsignedlong): cint{.extdecl, importc: "addrawch",
     dynlib: pdcursesdll.}
-proc insrawch*(a2: cunsignedlong): cint{.extdecl, importc: "insrawch", 
+proc insrawch*(a2: cunsignedlong): cint{.extdecl, importc: "insrawch",
     dynlib: pdcursesdll.}
-proc is_termresized*(): cunsignedchar{.extdecl, importc: "is_termresized", 
+proc is_termresized*(): cunsignedchar{.extdecl, importc: "is_termresized",
                                        dynlib: pdcursesdll.}
-proc mvaddrawch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl, 
+proc mvaddrawch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl,
     importc: "mvaddrawch", dynlib: pdcursesdll.}
-proc mvdeleteln*(a2: cint; a3: cint): cint{.extdecl, importc: "mvdeleteln", 
+proc mvdeleteln*(a2: cint; a3: cint): cint{.extdecl, importc: "mvdeleteln",
     dynlib: pdcursesdll.}
-proc mvinsertln*(a2: cint; a3: cint): cint{.extdecl, importc: "mvinsertln", 
+proc mvinsertln*(a2: cint; a3: cint): cint{.extdecl, importc: "mvinsertln",
     dynlib: pdcursesdll.}
-proc mvinsrawch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl, 
+proc mvinsrawch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl,
     importc: "mvinsrawch", dynlib: pdcursesdll.}
 proc mvwaddrawch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{.
     extdecl, importc: "mvwaddrawch", dynlib: pdcursesdll.}
-proc mvwdeleteln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc mvwdeleteln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "mvwdeleteln", dynlib: pdcursesdll.}
-proc mvwinsertln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, 
+proc mvwinsertln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl,
     importc: "mvwinsertln", dynlib: pdcursesdll.}
 proc mvwinsrawch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{.
     extdecl, importc: "mvwinsrawch", dynlib: pdcursesdll.}
-proc raw_output*(a2: cunsignedchar): cint{.extdecl, importc: "raw_output", 
+proc raw_output*(a2: cunsignedchar): cint{.extdecl, importc: "raw_output",
     dynlib: pdcursesdll.}
-proc resize_term*(a2: cint; a3: cint): cint{.extdecl, importc: "resize_term", 
+proc resize_term*(a2: cint; a3: cint): cint{.extdecl, importc: "resize_term",
     dynlib: pdcursesdll.}
-proc resize_window*(a2: ptr WINDOW; a3: cint; a4: cint): ptr WINDOW{.extdecl, 
+proc resize_window*(a2: ptr WINDOW; a3: cint; a4: cint): ptr WINDOW{.extdecl,
     importc: "resize_window", dynlib: pdcursesdll.}
-proc waddrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc waddrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "waddrawch", dynlib: pdcursesdll.}
-proc winsrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, 
+proc winsrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl,
     importc: "winsrawch", dynlib: pdcursesdll.}
 proc wordchar*(): char{.extdecl, importc: "wordchar", dynlib: pdcursesdll.}
-proc slk_wlabel*(a2: cint): cstring{.extdecl, importc: "slk_wlabel", 
+proc slk_wlabel*(a2: cint): cstring{.extdecl, importc: "slk_wlabel",
     dynlib: pdcursesdll.}
-proc debug*(a2: cstring){.varargs, extdecl, importc: "PDC_debug", 
+proc debug*(a2: cstring){.varargs, extdecl, importc: "PDC_debug",
                           dynlib: pdcursesdll.}
-proc ungetch*(a2: cint): cint{.extdecl, importc: "PDC_ungetch", 
+proc ungetch*(a2: cint): cint{.extdecl, importc: "PDC_ungetch",
                                dynlib: pdcursesdll.}
-proc set_blink*(a2: cunsignedchar): cint{.extdecl, importc: "PDC_set_blink", 
+proc set_blink*(a2: cunsignedchar): cint{.extdecl, importc: "PDC_set_blink",
     dynlib: pdcursesdll.}
-proc set_line_color*(a2: cshort): cint{.extdecl, importc: "PDC_set_line_color", 
+proc set_line_color*(a2: cshort): cint{.extdecl, importc: "PDC_set_line_color",
                                         dynlib: pdcursesdll.}
-proc set_title*(a2: cstring){.extdecl, importc: "PDC_set_title", 
+proc set_title*(a2: cstring){.extdecl, importc: "PDC_set_title",
                               dynlib: pdcursesdll.}
-proc clearclipboard*(): cint{.extdecl, importc: "PDC_clearclipboard", 
+proc clearclipboard*(): cint{.extdecl, importc: "PDC_clearclipboard",
                               dynlib: pdcursesdll.}
-proc freeclipboard*(a2: cstring): cint{.extdecl, importc: "PDC_freeclipboard", 
+proc freeclipboard*(a2: cstring): cint{.extdecl, importc: "PDC_freeclipboard",
                                         dynlib: pdcursesdll.}
-proc getclipboard*(a2: cstringArray; a3: ptr clong): cint{.extdecl, 
+proc getclipboard*(a2: cstringArray; a3: ptr clong): cint{.extdecl,
     importc: "PDC_getclipboard", dynlib: pdcursesdll.}
-proc setclipboard*(a2: cstring; a3: clong): cint{.extdecl, 
+proc setclipboard*(a2: cstring; a3: clong): cint{.extdecl,
     importc: "PDC_setclipboard", dynlib: pdcursesdll.}
-proc get_input_fd*(): cunsignedlong{.extdecl, importc: "PDC_get_input_fd", 
+proc get_input_fd*(): cunsignedlong{.extdecl, importc: "PDC_get_input_fd",
                                      dynlib: pdcursesdll.}
-proc get_key_modifiers*(): cunsignedlong{.extdecl, 
+proc get_key_modifiers*(): cunsignedlong{.extdecl,
     importc: "PDC_get_key_modifiers", dynlib: pdcursesdll.}
-proc return_key_modifiers*(a2: cunsignedchar): cint{.extdecl, 
+proc return_key_modifiers*(a2: cunsignedchar): cint{.extdecl,
     importc: "PDC_return_key_modifiers", dynlib: pdcursesdll.}
-proc save_key_modifiers*(a2: cunsignedchar): cint{.extdecl, 
+proc save_key_modifiers*(a2: cunsignedchar): cint{.extdecl,
     importc: "PDC_save_key_modifiers", dynlib: pdcursesdll.}
-proc bottom_panel*(pan: ptr PANEL): cint{.extdecl, importc: "bottom_panel", 
+proc bottom_panel*(pan: ptr PANEL): cint{.extdecl, importc: "bottom_panel",
     dynlib: pdcursesdll.}
-proc del_panel*(pan: ptr PANEL): cint{.extdecl, importc: "del_panel", 
+proc del_panel*(pan: ptr PANEL): cint{.extdecl, importc: "del_panel",
                                        dynlib: pdcursesdll.}
-proc hide_panel*(pan: ptr PANEL): cint{.extdecl, importc: "hide_panel", 
+proc hide_panel*(pan: ptr PANEL): cint{.extdecl, importc: "hide_panel",
                                         dynlib: pdcursesdll.}
-proc move_panel*(pan: ptr PANEL; starty: cint; startx: cint): cint{.extdecl, 
+proc move_panel*(pan: ptr PANEL; starty: cint; startx: cint): cint{.extdecl,
     importc: "move_panel", dynlib: pdcursesdll.}
-proc new_panel*(win: ptr WINDOW): ptr PANEL{.extdecl, importc: "new_panel", 
+proc new_panel*(win: ptr WINDOW): ptr PANEL{.extdecl, importc: "new_panel",
     dynlib: pdcursesdll.}
-proc panel_above*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_above", 
+proc panel_above*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_above",
     dynlib: pdcursesdll.}
-proc panel_below*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_below", 
+proc panel_below*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_below",
     dynlib: pdcursesdll.}
-proc panel_hidden*(pan: ptr PANEL): cint{.extdecl, importc: "panel_hidden", 
+proc panel_hidden*(pan: ptr PANEL): cint{.extdecl, importc: "panel_hidden",
     dynlib: pdcursesdll.}
-proc panel_userptr*(pan: ptr PANEL): pointer{.extdecl, importc: "panel_userptr", 
+proc panel_userptr*(pan: ptr PANEL): pointer{.extdecl, importc: "panel_userptr",
     dynlib: pdcursesdll.}
-proc panel_window*(pan: ptr PANEL): ptr WINDOW{.extdecl, importc: "panel_window", 
+proc panel_window*(pan: ptr PANEL): ptr WINDOW{.extdecl, importc: "panel_window",
     dynlib: pdcursesdll.}
-proc replace_panel*(pan: ptr PANEL; win: ptr WINDOW): cint{.extdecl, 
+proc replace_panel*(pan: ptr PANEL; win: ptr WINDOW): cint{.extdecl,
     importc: "replace_panel", dynlib: pdcursesdll.}
-proc set_panel_userptr*(pan: ptr PANEL; uptr: pointer): cint{.extdecl, 
+proc set_panel_userptr*(pan: ptr PANEL; uptr: pointer): cint{.extdecl,
     importc: "set_panel_userptr", dynlib: pdcursesdll.}
-proc show_panel*(pan: ptr PANEL): cint{.extdecl, importc: "show_panel", 
+proc show_panel*(pan: ptr PANEL): cint{.extdecl, importc: "show_panel",
                                         dynlib: pdcursesdll.}
-proc top_panel*(pan: ptr PANEL): cint{.extdecl, importc: "top_panel", 
+proc top_panel*(pan: ptr PANEL): cint{.extdecl, importc: "top_panel",
                                        dynlib: pdcursesdll.}
 proc update_panels*(){.extdecl, importc: "update_panels", dynlib: pdcursesdll.}
 
 when unixOS:
-  proc Xinitscr*(a2: cint; a3: cstringArray): ptr WINDOW{.extdecl, 
+  proc Xinitscr*(a2: cint; a3: cstringArray): ptr WINDOW{.extdecl,
     importc: "Xinitscr", dynlib: pdcursesdll.}
   proc XCursesExit*(){.extdecl, importc: "XCursesExit", dynlib: pdcursesdll.}
   proc sb_init*(): cint{.extdecl, importc: "sb_init", dynlib: pdcursesdll.}
-  proc sb_set_horz*(a2: cint; a3: cint; a4: cint): cint{.extdecl, 
+  proc sb_set_horz*(a2: cint; a3: cint; a4: cint): cint{.extdecl,
     importc: "sb_set_horz", dynlib: pdcursesdll.}
-  proc sb_set_vert*(a2: cint; a3: cint; a4: cint): cint{.extdecl, 
+  proc sb_set_vert*(a2: cint; a3: cint; a4: cint): cint{.extdecl,
     importc: "sb_set_vert", dynlib: pdcursesdll.}
-  proc sb_get_horz*(a2: ptr cint; a3: ptr cint; a4: ptr cint): cint{.extdecl, 
+  proc sb_get_horz*(a2: ptr cint; a3: ptr cint; a4: ptr cint): cint{.extdecl,
     importc: "sb_get_horz", dynlib: pdcursesdll.}
-  proc sb_get_vert*(a2: ptr cint; a3: ptr cint; a4: ptr cint): cint{.extdecl, 
+  proc sb_get_vert*(a2: ptr cint; a3: ptr cint; a4: ptr cint): cint{.extdecl,
     importc: "sb_get_vert", dynlib: pdcursesdll.}
   proc sb_refresh*(): cint{.extdecl, importc: "sb_refresh", dynlib: pdcursesdll.}
 
-template getch*(): expr = 
+template getch*(): expr =
   wgetch(stdscr)
 
-template ungetch*(ch: expr): expr = 
+template ungetch*(ch: expr): expr =
   ungetch(ch)
 
 template getbegyx*(w, y, x: expr): expr =
@@ -1525,13 +1534,13 @@ template getyx*(w, y, x: expr): expr =
   y = getcury(w)
   x = getcurx(w)
 
-template getsyx*(y, x: expr): stmt = 
+template getsyx*(y, x: expr): stmt =
   if curscr.leaveit:
     (x) = - 1
     (y) = (x)
   else: getyx(curscr, (y), (x))
-  
-template getmouse*(x: expr): expr = 
+
+template getmouse*(x: expr): expr =
   nc_getmouse(x)
 
 when defined(windows):
@@ -1541,5 +1550,5 @@ when defined(windows):
     con_in*{.importc: "pdc_con_in", dynlib: pdcursesdll.}: HANDLE
     quick_edit*{.importc: "pdc_quick_edit", dynlib: pdcursesdll.}: DWORD
 
-  proc get_buffer_rows*(): cint{.extdecl, importc: "PDC_get_buffer_rows", 
+  proc get_buffer_rows*(): cint{.extdecl, importc: "PDC_get_buffer_rows",
                                dynlib: pdcursesdll.}
diff --git a/lib/wrappers/postgres.nim b/lib/wrappers/postgres.nim
index 3c35bc590..f9a10dccb 100644
--- a/lib/wrappers/postgres.nim
+++ b/lib/wrappers/postgres.nim
@@ -1,3 +1,12 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
 # This module contains the definitions for structures and externs for
 # functions used by frontend postgres applications. It is based on
 # Postgresql's libpq-fe.h.
@@ -8,43 +17,43 @@
 
 {.deadCodeElim: on.}
 
-when defined(windows): 
-  const 
+when defined(windows):
+  const
     dllName = "libpq.dll"
-elif defined(macosx): 
-  const 
+elif defined(macosx):
+  const
     dllName = "libpq.dylib"
-else: 
-  const 
+else:
+  const
     dllName = "libpq.so(.5|)"
-type 
+type
   POid* = ptr Oid
   Oid* = int32
 
-const 
+const
   ERROR_MSG_LENGTH* = 4096
   CMDSTATUS_LEN* = 40
 
-type 
+type
   SockAddr* = array[1..112, int8]
-  PGresAttDesc*{.pure, final.} = object 
+  PGresAttDesc*{.pure, final.} = object
     name*: cstring
     adtid*: Oid
     adtsize*: int
 
   PPGresAttDesc* = ptr PGresAttDesc
   PPPGresAttDesc* = ptr PPGresAttDesc
-  PGresAttValue*{.pure, final.} = object 
+  PGresAttValue*{.pure, final.} = object
     length*: int32
     value*: cstring
 
   PPGresAttValue* = ptr PGresAttValue
   PPPGresAttValue* = ptr PPGresAttValue
   PExecStatusType* = ptr ExecStatusType
-  ExecStatusType* = enum 
-    PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, 
+  ExecStatusType* = enum
+    PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT,
     PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR
-  PGlobjfuncs*{.pure, final.} = object 
+  PGlobjfuncs*{.pure, final.} = object
     fn_lo_open*: Oid
     fn_lo_close*: Oid
     fn_lo_creat*: Oid
@@ -56,11 +65,11 @@ type
 
   PPGlobjfuncs* = ptr PGlobjfuncs
   PConnStatusType* = ptr ConnStatusType
-  ConnStatusType* = enum 
-    CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, 
-    CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, 
+  ConnStatusType* = enum
+    CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE,
+    CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV,
     CONNECTION_SSL_STARTUP, CONNECTION_NEEDED
-  PGconn*{.pure, final.} = object 
+  PGconn*{.pure, final.} = object
     pghost*: cstring
     pgtty*: cstring
     pgport*: cstring
@@ -82,7 +91,7 @@ type
     lobjfuncs*: PPGlobjfuncs
 
   PPGconn* = ptr PGconn
-  PGresult*{.pure, final.} = object 
+  PGresult*{.pure, final.} = object
     ntups*: int32
     numAttributes*: int32
     attDescs*: PPGresAttDesc
@@ -95,18 +104,18 @@ type
 
   PPGresult* = ptr PGresult
   PPostgresPollingStatusType* = ptr PostgresPollingStatusType
-  PostgresPollingStatusType* = enum 
-    PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING, 
+  PostgresPollingStatusType* = enum
+    PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING,
     PGRES_POLLING_OK, PGRES_POLLING_ACTIVE
   PPGTransactionStatusType* = ptr PGTransactionStatusType
-  PGTransactionStatusType* = enum 
-    PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR, 
+  PGTransactionStatusType* = enum
+    PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR,
     PQTRANS_UNKNOWN
   PPGVerbosity* = ptr PGVerbosity
-  PGVerbosity* = enum 
+  PGVerbosity* = enum
     PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE
   PpgNotify* = ptr pgNotify
-  pgNotify*{.pure, final.} = object 
+  pgNotify*{.pure, final.} = object
     relname*: cstring
     be_pid*: int32
     extra*: cstring
@@ -116,7 +125,7 @@ type
   Ppqbool* = ptr pqbool
   pqbool* = char
   P_PQprintOpt* = ptr PQprintOpt
-  PQprintOpt*{.pure, final.} = object 
+  PQprintOpt*{.pure, final.} = object
     header*: pqbool
     align*: pqbool
     standard*: pqbool
@@ -129,7 +138,7 @@ type
     fieldName*: ptr cstring
 
   P_PQconninfoOption* = ptr PQconninfoOption
-  PQconninfoOption*{.pure, final.} = object 
+  PQconninfoOption*{.pure, final.} = object
     keyword*: cstring
     envvar*: cstring
     compiled*: cstring
@@ -139,7 +148,7 @@ type
     dispsize*: int32
 
   PPQArgBlock* = ptr PQArgBlock
-  PQArgBlock*{.pure, final.} = object 
+  PQArgBlock*{.pure, final.} = object
     length*: int32
     isint*: int32
     p*: pointer
@@ -148,27 +157,27 @@ type
       TPGlobjfuncs: Pglobjfuncs, TConnStatusType: ConnStatusType, TPGconn: Pgconn,
       TPGresult: PGresult].}
 
-proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
+proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
     importc: "PQconnectStart".}
-proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
+proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
     dynlib: dllName, importc: "PQconnectPoll".}
-proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
+proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
     importc: "PQconnectdb".}
-proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring, 
+proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
                    pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
     cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
 proc pqsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): Ppgconn
 proc pqfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
-proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName, 
+proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
     importc: "PQconndefaults".}
-proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName, 
+proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
     importc: "PQconninfoFree".}
-proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQresetStart".}
-proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
+proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
     dynlib: dllName, importc: "PQresetPoll".}
 proc pqreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
-proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQrequestCancel".}
 proc pqdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
 proc pquser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
@@ -176,44 +185,44 @@ proc pqpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".
 proc pqhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
 proc pqport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
 proc pqtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
-proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
+proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
     importc: "PQoptions".}
-proc pqstatus*(conn: PPGconn): ConnStatusType{.cdecl, dynlib: dllName, 
+proc pqstatus*(conn: PPGconn): ConnStatusType{.cdecl, dynlib: dllName,
     importc: "PQstatus".}
-proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl, 
+proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
     dynlib: dllName, importc: "PQtransactionStatus".}
-proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl, 
+proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
     dynlib: dllName, importc: "PQparameterStatus".}
-proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQprotocolVersion".}
-proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
+proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
     importc: "PQerrorMessage".}
-proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
                                       importc: "PQsocket".}
-proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQbackendPID".}
-proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQclientEncoding".}
-proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl, 
+proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
     dynlib: dllName, importc: "PQsetClientEncoding".}
-when defined(USE_SSL): 
-  # Get the SSL structure associated with a connection  
-  proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName, 
+when defined(USE_SSL):
+  # Get the SSL structure associated with a connection
+  proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
                                        importc: "PQgetssl".}
 proc pqsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
     cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
-proc pqtrace*(conn: PPGconn, debug_port: File){.cdecl, dynlib: dllName, 
+proc pqtrace*(conn: PPGconn, debug_port: File){.cdecl, dynlib: dllName,
     importc: "PQtrace".}
 proc pquntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
 proc pqsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
     cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
-proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor, 
-                           arg: pointer): PQnoticeProcessor{.cdecl, 
+proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
+                           arg: pointer): PQnoticeProcessor{.cdecl,
     dynlib: dllName, importc: "PQsetNoticeProcessor".}
-proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName, 
+proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
     importc: "PQexec".}
-proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                   paramTypes: POid, paramValues: cstringArray, 
+proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32,
+                   paramTypes: POid, paramValues: cstringArray,
                    paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
     cdecl, dynlib: dllName, importc: "PQexecParams".}
 proc pqprepare*(conn: PPGconn, stmtName, query: cstring, nParams: int32,
@@ -222,87 +231,87 @@ proc pqexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
                      paramValues: cstringArray,
                      paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
     cdecl, dynlib: dllName, importc: "PQexecPrepared".}
-proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName, 
+proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
     importc: "PQsendQuery".}
-proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                        paramTypes: POid, paramValues: cstringArray, 
-                        paramLengths, paramFormats: ptr int32, 
-                        resultFormat: int32): int32{.cdecl, dynlib: dllName, 
+proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
+                        paramTypes: POid, paramValues: cstringArray,
+                        paramLengths, paramFormats: ptr int32,
+                        resultFormat: int32): int32{.cdecl, dynlib: dllName,
     importc: "PQsendQueryParams".}
-proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32, 
-                          paramValues: cstringArray, 
-                          paramLengths, paramFormats: ptr int32, 
-                          resultFormat: int32): int32{.cdecl, dynlib: dllName, 
+proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
+                          paramValues: cstringArray,
+                          paramLengths, paramFormats: ptr int32,
+                          resultFormat: int32): int32{.cdecl, dynlib: dllName,
     importc: "PQsendQueryPrepared".}
-proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName, 
+proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
     importc: "PQgetResult".}
-proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
                                       importc: "PQisBusy".}
-proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQconsumeInput".}
-proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName, 
+proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
     importc: "PQnotifies".}
 proc pqputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
     cdecl, dynlib: dllName, importc: "PQputCopyData".}
-proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl, 
+proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
     dynlib: dllName, importc: "PQputCopyEnd".}
 proc pqgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
     cdecl, dynlib: dllName, importc: "PQgetCopyData".}
-proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl, 
+proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
     dynlib: dllName, importc: "PQgetline".}
-proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName, 
+proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
     importc: "PQputline".}
 proc pqgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
     cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
-proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl, 
+proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
     dynlib: dllName, importc: "PQputnbytes".}
-proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
                                        importc: "PQendcopy".}
-proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl, 
+proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
     dynlib: dllName, importc: "PQsetnonblocking".}
-proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
+proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
     importc: "PQisnonblocking".}
 proc pqflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
-proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32, 
+proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
            result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
     cdecl, dynlib: dllName, importc: "PQfn".}
-proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName, 
+proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName,
     importc: "PQresultStatus".}
-proc pqresStatus*(status: ExecStatusType): cstring{.cdecl, dynlib: dllName, 
+proc pqresStatus*(status: ExecStatusType): cstring{.cdecl, dynlib: dllName,
     importc: "PQresStatus".}
-proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
+proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
     importc: "PQresultErrorMessage".}
-proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl, 
+proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
     dynlib: dllName, importc: "PQresultErrorField".}
-proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
+proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
                                         importc: "PQntuples".}
-proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
+proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
                                         importc: "PQnfields".}
-proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
+proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
     importc: "PQbinaryTuples".}
-proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl, 
+proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
     dynlib: dllName, importc: "PQfname".}
-proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl, 
+proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
     dynlib: dllName, importc: "PQfnumber".}
-proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
+proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
     importc: "PQftable".}
-proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl, 
+proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
     dynlib: dllName, importc: "PQftablecol".}
-proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl, 
+proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
     dynlib: dllName, importc: "PQfformat".}
-proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
+proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
     importc: "PQftype".}
-proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
+proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
     importc: "PQfsize".}
-proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
+proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
     importc: "PQfmod".}
-proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
+proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
     importc: "PQcmdStatus".}
-proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
+proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
     importc: "PQoidStatus".}
-proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName, 
+proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
                                        importc: "PQoidValue".}
-proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
+proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
     importc: "PQcmdTuples".}
 proc pqgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
     cdecl, dynlib: dllName, importc: "PQgetvalue".}
@@ -314,23 +323,23 @@ proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
 proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
 proc pqmakeEmptyPGresult*(conn: PPGconn, status: ExecStatusType): PPGresult{.
     cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
-proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl, 
+proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl,
     dynlib: dllName, importc: "PQescapeString".}
 proc pqescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
     cdecl, dynlib: dllName, importc: "PQescapeBytea".}
-proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl, 
+proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
     dynlib: dllName, importc: "PQunescapeBytea".}
-proc pqprint*(fout: File, res: PPGresult, ps: PPQprintOpt){.cdecl, 
+proc pqprint*(fout: File, res: PPGresult, ps: PPQprintOpt){.cdecl,
     dynlib: dllName, importc: "PQprint".}
-proc pqdisplayTuples*(res: PPGresult, fp: File, fillAlign: int32, 
+proc pqdisplayTuples*(res: PPGresult, fp: File, fillAlign: int32,
                       fieldSep: cstring, printHeader: int32, quiet: int32){.
     cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
-proc pqprintTuples*(res: PPGresult, fout: File, printAttName: int32, 
-                    terseOutput: int32, width: int32){.cdecl, dynlib: dllName, 
+proc pqprintTuples*(res: PPGresult, fout: File, printAttName: int32,
+                    terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
     importc: "PQprintTuples".}
-proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl, 
+proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
     dynlib: dllName, importc: "lo_open".}
-proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
+proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
     importc: "lo_close".}
 proc lo_read*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
     cdecl, dynlib: dllName, importc: "lo_read".}
@@ -338,18 +347,18 @@ proc lo_write*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
     cdecl, dynlib: dllName, importc: "lo_write".}
 proc lo_lseek*(conn: PPGconn, fd: int32, offset: int32, whence: int32): int32{.
     cdecl, dynlib: dllName, importc: "lo_lseek".}
-proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName, 
+proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName,
     importc: "lo_creat".}
-proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
+proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
     importc: "lo_tell".}
-proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName, 
+proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName,
     importc: "lo_unlink".}
-proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName, 
+proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
     importc: "lo_import".}
-proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl, 
+proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
     dynlib: dllName, importc: "lo_export".}
-proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName, 
+proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
     importc: "PQmblen".}
 proc pqenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
-proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn = 
+proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn =
   result = pqSetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
diff --git a/lib/wrappers/readline/history.nim b/lib/wrappers/readline/history.nim
deleted file mode 100644
index 610c76a62..000000000
--- a/lib/wrappers/readline/history.nim
+++ /dev/null
@@ -1,279 +0,0 @@
-# history.h -- the names of functions that you can call in history. 
-# Copyright (C) 1989-2009 Free Software Foundation, Inc.
-#
-#   This file contains the GNU History Library (History), a set of
-#   routines for managing the text of previously typed lines.
-#
-#   History is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   History is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with History.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-{.deadCodeElim: on.}
-
-import readline
-
-const 
-  historyDll = readlineDll
-
-import times, rltypedefs
-
-type 
-  Histdata* = pointer
-{.deprecated: [Thistdata: Histdata].}
-
-# The structure used to store a history entry. 
-
-type 
-  HIST_ENTRY*{.pure, final.} = object 
-    line*: cstring
-    timestamp*: cstring       # char * rather than time_t for read/write 
-    data*: Histdata
-{.deprecated: [THIST_ENTRY: HIST_ENTRY].}
-
-# Size of the history-library-managed space in history entry HS. 
-
-template HISTENT_BYTES*(hs: expr): expr = 
-  (strlen(hs.line) + strlen(hs.timestamp))
-
-# A structure used to pass the current state of the history stuff around. 
-
-type 
-  HISTORY_STATE*{.pure, final.} = object 
-    entries*: ptr ptr HIST_ENTRY # Pointer to the entries themselves. 
-    offset*: cint             # The location pointer within this array. 
-    length*: cint             # Number of elements within this array. 
-    size*: cint               # Number of slots allocated to this array. 
-    flags*: cint
-{.deprecated: [THISTORY_STATE: HISTORY_STATE].}
-
-
-# Flag values for the `flags' member of HISTORY_STATE. 
-
-const 
-  HS_STIFLED* = 0x00000001
-
-# Initialization and state management. 
-# Begin a session in which the history functions might be used.  This
-#   just initializes the interactive variables. 
-
-proc using_history*(){.cdecl, importc: "using_history", dynlib: historyDll.}
-# Return the current HISTORY_STATE of the history. 
-
-proc history_get_history_state*(): ptr HISTORY_STATE{.cdecl, 
-    importc: "history_get_history_state", dynlib: historyDll.}
-# Set the state of the current history array to STATE. 
-
-proc history_set_history_state*(a2: ptr HISTORY_STATE){.cdecl, 
-    importc: "history_set_history_state", dynlib: historyDll.}
-# Manage the history list. 
-# Place STRING at the end of the history list.
-#   The associated data field (if any) is set to NULL. 
-
-proc add_history*(a2: cstring){.cdecl, importc: "add_history", 
-                                dynlib: historyDll.}
-# Change the timestamp associated with the most recent history entry to
-#   STRING. 
-
-proc add_history_time*(a2: cstring){.cdecl, importc: "add_history_time", 
-                                     dynlib: historyDll.}
-# A reasonably useless function, only here for completeness.  WHICH
-#   is the magic number that tells us which element to delete.  The
-#   elements are numbered from 0. 
-
-proc remove_history*(a2: cint): ptr HIST_ENTRY{.cdecl, 
-    importc: "remove_history", dynlib: historyDll.}
-# Free the history entry H and return any application-specific data
-#   associated with it. 
-
-proc free_history_entry*(a2: ptr HIST_ENTRY): Histdata{.cdecl, 
-    importc: "free_history_entry", dynlib: historyDll.}
-# Make the history entry at WHICH have LINE and DATA.  This returns
-#   the old entry so you can dispose of the data.  In the case of an
-#   invalid WHICH, a NULL pointer is returned. 
-
-proc replace_history_entry*(a2: cint, a3: cstring, a4: Histdata): ptr HIST_ENTRY{.
-    cdecl, importc: "replace_history_entry", dynlib: historyDll.}
-# Clear the history list and start over. 
-
-proc clear_history*(){.cdecl, importc: "clear_history", dynlib: historyDll.}
-# Stifle the history list, remembering only MAX number of entries. 
-
-proc stifle_history*(a2: cint){.cdecl, importc: "stifle_history", 
-                                dynlib: historyDll.}
-# Stop stifling the history.  This returns the previous amount the
-#   history was stifled by.  The value is positive if the history was
-#   stifled, negative if it wasn't. 
-
-proc unstifle_history*(): cint{.cdecl, importc: "unstifle_history", 
-                                dynlib: historyDll.}
-# Return 1 if the history is stifled, 0 if it is not. 
-
-proc history_is_stifled*(): cint{.cdecl, importc: "history_is_stifled", 
-                                  dynlib: historyDll.}
-# Information about the history list. 
-# Return a NULL terminated array of HIST_ENTRY which is the current input
-#   history.  Element 0 of this list is the beginning of time.  If there
-#   is no history, return NULL. 
-
-proc history_list*(): ptr ptr HIST_ENTRY{.cdecl, importc: "history_list", 
-    dynlib: historyDll.}
-# Returns the number which says what history element we are now
-#   looking at.  
-
-proc where_history*(): cint{.cdecl, importc: "where_history", dynlib: historyDll.}
-# Return the history entry at the current position, as determined by
-#   history_offset.  If there is no entry there, return a NULL pointer. 
-
-proc current_history*(): ptr HIST_ENTRY{.cdecl, importc: "current_history", 
-    dynlib: historyDll.}
-# Return the history entry which is logically at OFFSET in the history
-#   array.  OFFSET is relative to history_base. 
-
-proc history_get*(a2: cint): ptr HIST_ENTRY{.cdecl, importc: "history_get", 
-    dynlib: historyDll.}
-# Return the timestamp associated with the HIST_ENTRY * passed as an
-#   argument 
-
-proc history_get_time*(a2: ptr HIST_ENTRY): Time{.cdecl, 
-    importc: "history_get_time", dynlib: historyDll.}
-# Return the number of bytes that the primary history entries are using.
-#   This just adds up the lengths of the_history->lines. 
-
-proc history_total_bytes*(): cint{.cdecl, importc: "history_total_bytes", 
-                                   dynlib: historyDll.}
-# Moving around the history list. 
-# Set the position in the history list to POS. 
-
-proc history_set_pos*(a2: cint): cint{.cdecl, importc: "history_set_pos", 
-                                       dynlib: historyDll.}
-# Back up history_offset to the previous history entry, and return
-#   a pointer to that entry.  If there is no previous entry, return
-#   a NULL pointer. 
-
-proc previous_history*(): ptr HIST_ENTRY{.cdecl, importc: "previous_history", 
-    dynlib: historyDll.}
-# Move history_offset forward to the next item in the input_history,
-#   and return the a pointer to that entry.  If there is no next entry,
-#   return a NULL pointer. 
-
-proc next_history*(): ptr HIST_ENTRY{.cdecl, importc: "next_history", 
-                                       dynlib: historyDll.}
-# Searching the history list. 
-# Search the history for STRING, starting at history_offset.
-#   If DIRECTION < 0, then the search is through previous entries,
-#   else through subsequent.  If the string is found, then
-#   current_history () is the history entry, and the value of this function
-#   is the offset in the line of that history entry that the string was
-#   found in.  Otherwise, nothing is changed, and a -1 is returned. 
-
-proc history_search*(a2: cstring, a3: cint): cint{.cdecl, 
-    importc: "history_search", dynlib: historyDll.}
-# Search the history for STRING, starting at history_offset.
-#   The search is anchored: matching lines must begin with string.
-#   DIRECTION is as in history_search(). 
-
-proc history_search_prefix*(a2: cstring, a3: cint): cint{.cdecl, 
-    importc: "history_search_prefix", dynlib: historyDll.}
-# Search for STRING in the history list, starting at POS, an
-#   absolute index into the list.  DIR, if negative, says to search
-#   backwards from POS, else forwards.
-#   Returns the absolute index of the history element where STRING
-#   was found, or -1 otherwise. 
-
-proc history_search_pos*(a2: cstring, a3: cint, a4: cint): cint{.cdecl, 
-    importc: "history_search_pos", dynlib: historyDll.}
-# Managing the history file. 
-# Add the contents of FILENAME to the history list, a line at a time.
-#   If FILENAME is NULL, then read from ~/.history.  Returns 0 if
-#   successful, or errno if not. 
-
-proc read_history*(a2: cstring): cint{.cdecl, importc: "read_history", 
-                                       dynlib: historyDll.}
-# Read a range of lines from FILENAME, adding them to the history list.
-#   Start reading at the FROM'th line and end at the TO'th.  If FROM
-#   is zero, start at the beginning.  If TO is less than FROM, read
-#   until the end of the file.  If FILENAME is NULL, then read from
-#   ~/.history.  Returns 0 if successful, or errno if not. 
-
-proc read_history_range*(a2: cstring, a3: cint, a4: cint): cint{.cdecl, 
-    importc: "read_history_range", dynlib: historyDll.}
-# Write the current history to FILENAME.  If FILENAME is NULL,
-#   then write the history list to ~/.history.  Values returned
-#   are as in read_history ().  
-
-proc write_history*(a2: cstring): cint{.cdecl, importc: "write_history", 
-                                        dynlib: historyDll.}
-# Append NELEMENT entries to FILENAME.  The entries appended are from
-#   the end of the list minus NELEMENTs up to the end of the list. 
-
-proc append_history*(a2: cint, a3: cstring): cint{.cdecl, 
-    importc: "append_history", dynlib: historyDll.}
-# Truncate the history file, leaving only the last NLINES lines. 
-
-proc history_truncate_file*(a2: cstring, a3: cint): cint{.cdecl, 
-    importc: "history_truncate_file", dynlib: historyDll.}
-# History expansion. 
-# Expand the string STRING, placing the result into OUTPUT, a pointer
-#   to a string.  Returns:
-#
-#   0) If no expansions took place (or, if the only change in
-#      the text was the de-slashifying of the history expansion
-#      character)
-#   1) If expansions did take place
-#  -1) If there was an error in expansion.
-#   2) If the returned line should just be printed.
-#
-#  If an error occurred in expansion, then OUTPUT contains a descriptive
-#  error message. 
-
-proc history_expand*(a2: cstring, a3: cstringArray): cint{.cdecl, 
-    importc: "history_expand", dynlib: historyDll.}
-# Extract a string segment consisting of the FIRST through LAST
-#   arguments present in STRING.  Arguments are broken up as in
-#   the shell. 
-
-proc history_arg_extract*(a2: cint, a3: cint, a4: cstring): cstring{.cdecl, 
-    importc: "history_arg_extract", dynlib: historyDll.}
-# Return the text of the history event beginning at the current
-#   offset into STRING.  Pass STRING with *INDEX equal to the
-#   history_expansion_char that begins this specification.
-#   DELIMITING_QUOTE is a character that is allowed to end the string
-#   specification for what to search for in addition to the normal
-#   characters `:', ` ', `\t', `\n', and sometimes `?'. 
-
-proc get_history_event*(a2: cstring, a3: ptr cint, a4: cint): cstring{.cdecl, 
-    importc: "get_history_event", dynlib: historyDll.}
-# Return an array of tokens, much as the shell might.  The tokens are
-#   parsed out of STRING. 
-
-proc history_tokenize*(a2: cstring): cstringArray{.cdecl, 
-    importc: "history_tokenize", dynlib: historyDll.}
-when false: 
-  # Exported history variables. 
-  var history_base*{.importc: "history_base", dynlib: historyDll.}: cint
-  var history_length*{.importc: "history_length", dynlib: historyDll.}: cint
-  var history_max_entries*{.importc: "history_max_entries", dynlib: historyDll.}: cint
-  var history_expansion_char*{.importc: "history_expansion_char", 
-                               dynlib: historyDll.}: char
-  var history_subst_char*{.importc: "history_subst_char", dynlib: historyDll.}: char
-  var history_word_delimiters*{.importc: "history_word_delimiters", 
-                                dynlib: historyDll.}: cstring
-  var history_comment_char*{.importc: "history_comment_char", dynlib: historyDll.}: char
-  var history_no_expand_chars*{.importc: "history_no_expand_chars", 
-                                dynlib: historyDll.}: cstring
-  var history_search_delimiter_chars*{.importc: "history_search_delimiter_chars", 
-                                       dynlib: historyDll.}: cstring
-  var history_quotes_inhibit_expansion*{.
-      importc: "history_quotes_inhibit_expansion", dynlib: historyDll.}: cint
-  var history_write_timestamps*{.importc: "history_write_timestamps", 
-                                 dynlib: historyDll.}: cint
diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim
deleted file mode 100644
index 652808576..000000000
--- a/lib/wrappers/readline/readline.nim
+++ /dev/null
@@ -1,1209 +0,0 @@
-# Readline.h -- the names of functions callable from within readline. 
-# Copyright (C) 1987-2009 Free Software Foundation, Inc.
-#
-#   This file is part of the GNU Readline Library (Readline), a library
-#   for reading lines of text with interactive input and history editing.      
-#
-#   Readline is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   Readline is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-{.deadCodeElim: on.}
-when defined(windows): 
-  const 
-    readlineDll* = "readline.dll"
-elif defined(macosx): 
-  # Mac OS X ships with 'libedit'
-  const 
-    readlineDll* = "libedit(.2|.1|).dylib"
-else: 
-  const 
-    readlineDll* = "libreadline.so.6(|.0)"
-#  mangle "'CommandFunc'" CommandFunc
-#  mangle TvcpFunc TvcpFunc
-
-import rltypedefs
-
-# Some character stuff. 
-
-const 
-  control_character_threshold* = 0x00000020 # Smaller than this is control. 
-  control_character_mask* = 0x0000001F # 0x20 - 1 
-  meta_character_threshold* = 0x0000007F # Larger than this is Meta. 
-  control_character_bit* = 0x00000040 # 0x000000, must be off. 
-  meta_character_bit* = 0x00000080 # x0000000, must be on. 
-  largest_char* = 255         # Largest character value. 
-
-template CTRL_CHAR*(c: expr): expr = 
-  (c < control_character_threshold and ((c and 0x00000080) == 0))
-
-template META_CHAR*(c: expr): expr = 
-  (c > meta_character_threshold and c <= largest_char)
-
-template CTRL*(c: expr): expr = 
-  (c and control_character_mask)
-
-template META*(c: expr): expr = 
-  (c or meta_character_bit)
-
-template UNMETA*(c: expr): expr = 
-  (c and not meta_character_bit)
-
-template UNCTRL*(c: expr): expr = 
-  (c or 32 or control_character_bit)
-
-# Beware:  these only work with single-byte ASCII characters. 
-
-const 
-  RETURN_CHAR* = CTRL('M'.ord)
-  RUBOUT_CHAR* = 0x0000007F
-  ABORT_CHAR* = CTRL('G'.ord)
-  PAGE_CHAR* = CTRL('L'.ord)
-  ESC_CHAR* = CTRL('['.ord)
-
-# A keymap contains one entry for each key in the ASCII set.
-#   Each entry consists of a type and a pointer.
-#   FUNCTION is the address of a function to run, or the
-#   address of a keymap to indirect through.
-#   TYPE says which kind of thing FUNCTION is. 
-
-type 
-  KEYMAP_ENTRY*{.pure, final.} = object 
-    typ*: char
-    function*: CommandFunc
-{.deprecated: [TKEYMAP_ENTRY: KEYMAP_ENTRY].}
-
-
-# This must be large enough to hold bindings for all of the characters
-#   in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
-#   and so on) plus one for subsequence matching. 
-
-const 
-  KEYMAP_SIZE* = 257
-  ANYOTHERKEY* = KEYMAP_SIZE - 1
-
-# I wanted to make the above structure contain a union of:
-#   union { rl_TCommandFunc_t *function; struct _keymap_entry *keymap; } value;
-#   but this made it impossible for me to create a static array.
-#   Maybe I need C lessons. 
-
-type 
-  KEYMAP_ENTRY_ARRAY* = array[0..KEYMAP_SIZE - 1, KEYMAP_ENTRY]
-  PKeymap* = ptr KEYMAP_ENTRY
-{.deprecated: [TKEYMAP_ENTRY_ARRAY: KEYMAP_ENTRY_ARRAY].}
-
-# The values that TYPE can have in a keymap entry. 
-
-const 
-  ISFUNC* = 0
-  ISKMAP* = 1
-  ISMACR* = 2
-
-when false: 
-  var 
-    emacs_standard_keymap*{.importc: "emacs_standard_keymap", 
-                            dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
-    emacs_meta_keymap*{.importc: "emacs_meta_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
-    emacs_ctlx_keymap*{.importc: "emacs_ctlx_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
-  var 
-    vi_insertion_keymap*{.importc: "vi_insertion_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
-    vi_movement_keymap*{.importc: "vi_movement_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
-# Return a new, empty keymap.
-#   Free it with free() when you are done. 
-
-proc make_bare_keymap*(): PKeymap{.cdecl, importc: "rl_make_bare_keymap", 
-                                   dynlib: readlineDll.}
-# Return a new keymap which is a copy of MAP. 
-
-proc copy_keymap*(a2: PKeymap): PKeymap{.cdecl, importc: "rl_copy_keymap", 
-    dynlib: readlineDll.}
-# Return a new keymap with the printing characters bound to rl_insert,
-#   the lowercase Meta characters bound to run their equivalents, and
-#   the Meta digits bound to produce numeric arguments. 
-
-proc make_keymap*(): PKeymap{.cdecl, importc: "rl_make_keymap", 
-                              dynlib: readlineDll.}
-# Free the storage associated with a keymap. 
-
-proc discard_keymap*(a2: PKeymap){.cdecl, importc: "rl_discard_keymap", 
-                                   dynlib: readlineDll.}
-# These functions actually appear in bind.c 
-# Return the keymap corresponding to a given name.  Names look like
-#   `emacs' or `emacs-meta' or `vi-insert'.  
-
-proc get_keymap_by_name*(a2: cstring): PKeymap{.cdecl, 
-    importc: "rl_get_keymap_by_name", dynlib: readlineDll.}
-# Return the current keymap. 
-
-proc get_keymap*(): PKeymap{.cdecl, importc: "rl_get_keymap", 
-                             dynlib: readlineDll.}
-# Set the current keymap to MAP. 
-
-proc set_keymap*(a2: PKeymap){.cdecl, importc: "rl_set_keymap", 
-                               dynlib: readlineDll.}
-
-const 
-  tildeDll = readlineDll
-
-type 
-  Hook_func* = proc (a2: cstring): cstring{.cdecl.}
-{.deprecated: [Thook_func: Hook_func].}
-
-when not defined(macosx):
-  # If non-null, this contains the address of a function that the application
-  #   wants called before trying the standard tilde expansions.  The function
-  #   is called with the text sans tilde, and returns a malloc()'ed string
-  #   which is the expansion, or a NULL pointer if the expansion fails. 
-
-  var expansion_preexpansion_hook*{.importc: "tilde_expansion_preexpansion_hook", 
-                                    dynlib: tildeDll.}: Hook_func
-
-  # If non-null, this contains the address of a function to call if the
-  #   standard meaning for expanding a tilde fails.  The function is called
-  #   with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
-  #   which is the expansion, or a NULL pointer if there is no expansion. 
-
-  var expansion_failure_hook*{.importc: "tilde_expansion_failure_hook", 
-                               dynlib: tildeDll.}: Hook_func
-
-  # When non-null, this is a NULL terminated array of strings which
-  #   are duplicates for a tilde prefix.  Bash uses this to expand
-  #   `=~' and `:~'. 
-
-  var additional_prefixes*{.importc: "tilde_additional_prefixes", dynlib: tildeDll.}: cstringArray
-
-  # When non-null, this is a NULL terminated array of strings which match
-  #   the end of a username, instead of just "/".  Bash sets this to
-  #   `:' and `=~'. 
-
-  var additional_suffixes*{.importc: "tilde_additional_suffixes", dynlib: tildeDll.}: cstringArray
-
-# Return a new string which is the result of tilde expanding STRING. 
-
-proc expand*(a2: cstring): cstring{.cdecl, importc: "tilde_expand", 
-                                    dynlib: tildeDll.}
-# Do the work of tilde expansion on FILENAME.  FILENAME starts with a
-#   tilde.  If there is no expansion, call tilde_expansion_failure_hook. 
-
-proc expand_word*(a2: cstring): cstring{.cdecl, importc: "tilde_expand_word", 
-    dynlib: tildeDll.}
-# Find the portion of the string beginning with ~ that should be expanded. 
-
-proc find_word*(a2: cstring, a3: cint, a4: ptr cint): cstring{.cdecl, 
-    importc: "tilde_find_word", dynlib: tildeDll.}
-
-# Hex-encoded Readline version number. 
-
-const 
-  READLINE_VERSION* = 0x00000600 # Readline 6.0 
-  VERSION_MAJOR* = 6
-  VERSION_MINOR* = 0
-
-# Readline data structures. 
-# Maintaining the state of undo.  We remember individual deletes and inserts
-#   on a chain of things to do. 
-# The actions that undo knows how to undo.  Notice that UNDO_DELETE means
-#   to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
-#   the code tells undo what to undo, not how to undo it. 
-
-type 
-  Undo_code* = enum 
-    UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END
-{.deprecated: [Tundo_code: Undo_code].}
-
-# What an element of THE_UNDO_LIST looks like. 
-
-type 
-  UNDO_LIST*{.pure, final.} = object 
-    next*: ptr UNDO_LIST
-    start*: cint
-    theEnd*: cint             # Where the change took place. 
-    text*: cstring            # The text to insert, if undoing a delete. 
-    what*: Undo_code          # Delete, Insert, Begin, End. 
-{.deprecated: [TUNDO_LIST: UNDO_LIST].}
-  
-
-# The current undo list for RL_LINE_BUFFER. 
-
-when not defined(macosx):
-  var undo_list*{.importc: "rl_undo_list", dynlib: readlineDll.}: ptr UNDO_LIST
-
-# The data structure for mapping textual names to code addresses. 
-
-type 
-  FUNMAP*{.pure, final.} = object 
-    name*: cstring
-    function*: CommandFunc
-{.deprecated: [TFUNMAP: FUNMAP].}
-
-
-when not defined(macosx):
-  var funmap*{.importc: "funmap", dynlib: readlineDll.}: ptr ptr FUNMAP
-
-# **************************************************************** 
-#								    
-#	     Functions available to bind to key sequences	    
-#								    
-# **************************************************************** 
-# Bindable commands for numeric arguments. 
-
-proc digit_argument*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_digit_argument", dynlib: readlineDll.}
-proc universal_argument*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_universal_argument", dynlib: readlineDll.}
-# Bindable commands for moving the cursor. 
-
-proc forward_byte*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_byte", 
-    dynlib: readlineDll.}
-proc forward_char*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_char", 
-    dynlib: readlineDll.}
-proc forward*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward", 
-    dynlib: readlineDll.}
-proc backward_byte*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_byte", dynlib: readlineDll.}
-proc backward_char*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_char", dynlib: readlineDll.}
-proc backward*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_backward", 
-    dynlib: readlineDll.}
-proc beg_of_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_beg_of_line", 
-    dynlib: readlineDll.}
-proc end_of_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_end_of_line", 
-    dynlib: readlineDll.}
-proc forward_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_word", 
-    dynlib: readlineDll.}
-proc backward_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_word", dynlib: readlineDll.}
-proc refresh_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_refresh_line", 
-    dynlib: readlineDll.}
-proc clear_screen*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_clear_screen", 
-    dynlib: readlineDll.}
-proc skip_csi_sequence*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_skip_csi_sequence", dynlib: readlineDll.}
-proc arrow_keys*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_arrow_keys", 
-    dynlib: readlineDll.}
-# Bindable commands for inserting and deleting text. 
-
-proc insert*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_insert", 
-                                        dynlib: readlineDll.}
-proc quoted_insert*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_quoted_insert", dynlib: readlineDll.}
-proc tab_insert*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tab_insert", 
-    dynlib: readlineDll.}
-proc newline*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_newline", 
-    dynlib: readlineDll.}
-proc do_lowercase_version*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_do_lowercase_version", dynlib: readlineDll.}
-proc rubout*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_rubout", 
-                                        dynlib: readlineDll.}
-proc delete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_delete", 
-                                        dynlib: readlineDll.}
-proc rubout_or_delete*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_rubout_or_delete", dynlib: readlineDll.}
-proc delete_horizontal_space*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_delete_horizontal_space", dynlib: readlineDll.}
-proc delete_or_show_completions*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_delete_or_show_completions", dynlib: readlineDll.}
-proc insert_comment*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_insert_comment", dynlib: readlineDll.}
-# Bindable commands for changing case. 
-
-proc upcase_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_upcase_word", 
-    dynlib: readlineDll.}
-proc downcase_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_downcase_word", dynlib: readlineDll.}
-proc capitalize_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_capitalize_word", dynlib: readlineDll.}
-# Bindable commands for transposing characters and words. 
-
-proc transpose_words*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_transpose_words", dynlib: readlineDll.}
-proc transpose_chars*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_transpose_chars", dynlib: readlineDll.}
-# Bindable commands for searching within a line. 
-
-proc char_search*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_char_search", 
-    dynlib: readlineDll.}
-proc backward_char_search*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_char_search", dynlib: readlineDll.}
-# Bindable commands for readline's interface to the command history. 
-
-proc beginning_of_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_beginning_of_history", dynlib: readlineDll.}
-proc end_of_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_end_of_history", dynlib: readlineDll.}
-proc get_next_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_get_next_history", dynlib: readlineDll.}
-proc get_previous_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_get_previous_history", dynlib: readlineDll.}
-# Bindable commands for managing the mark and region. 
-
-proc set_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_set_mark", 
-    dynlib: readlineDll.}
-proc exchange_point_and_mark*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_exchange_point_and_mark", dynlib: readlineDll.}
-# Bindable commands to set the editing mode (emacs or vi). 
-
-proc vi_editing_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_editing_mode", dynlib: readlineDll.}
-proc emacs_editing_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_emacs_editing_mode", dynlib: readlineDll.}
-# Bindable commands to change the insert mode (insert or overwrite) 
-
-proc overwrite_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_overwrite_mode", dynlib: readlineDll.}
-# Bindable commands for managing key bindings. 
-
-proc re_read_init_file*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_re_read_init_file", dynlib: readlineDll.}
-proc dump_functions*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_dump_functions", dynlib: readlineDll.}
-proc dump_macros*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_dump_macros", 
-    dynlib: readlineDll.}
-proc dump_variables*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_dump_variables", dynlib: readlineDll.}
-# Bindable commands for word completion. 
-
-proc complete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_complete", 
-    dynlib: readlineDll.}
-proc possible_completions*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_possible_completions", dynlib: readlineDll.}
-proc insert_completions*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_insert_completions", dynlib: readlineDll.}
-proc old_menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_old_menu_complete", dynlib: readlineDll.}
-proc menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_menu_complete", dynlib: readlineDll.}
-proc backward_menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_menu_complete", dynlib: readlineDll.}
-# Bindable commands for killing and yanking text, and managing the kill ring. 
-
-proc kill_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_word", 
-    dynlib: readlineDll.}
-proc backward_kill_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_kill_word", dynlib: readlineDll.}
-proc kill_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_line", 
-    dynlib: readlineDll.}
-proc backward_kill_line*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_backward_kill_line", dynlib: readlineDll.}
-proc kill_full_line*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_kill_full_line", dynlib: readlineDll.}
-proc unix_word_rubout*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_unix_word_rubout", dynlib: readlineDll.}
-proc unix_filename_rubout*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_unix_filename_rubout", dynlib: readlineDll.}
-proc unix_line_discard*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_unix_line_discard", dynlib: readlineDll.}
-proc copy_region_to_kill*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_copy_region_to_kill", dynlib: readlineDll.}
-proc kill_region*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_region", 
-    dynlib: readlineDll.}
-proc copy_forward_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_copy_forward_word", dynlib: readlineDll.}
-proc copy_backward_word*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_copy_backward_word", dynlib: readlineDll.}
-proc yank*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank", 
-                                      dynlib: readlineDll.}
-proc yank_pop*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank_pop", 
-    dynlib: readlineDll.}
-proc yank_nth_arg*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank_nth_arg", 
-    dynlib: readlineDll.}
-proc yank_last_arg*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_yank_last_arg", dynlib: readlineDll.}
-when defined(Windows): 
-  proc paste_from_clipboard*(a2: cint, a3: cint): cint{.cdecl, 
-      importc: "rl_paste_from_clipboard", dynlib: readlineDll.}
-# Bindable commands for incremental searching. 
-
-proc reverse_search_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_reverse_search_history", dynlib: readlineDll.}
-proc forward_search_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_forward_search_history", dynlib: readlineDll.}
-# Bindable keyboard macro commands. 
-
-proc start_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_start_kbd_macro", dynlib: readlineDll.}
-proc end_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_end_kbd_macro", dynlib: readlineDll.}
-proc call_last_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_call_last_kbd_macro", dynlib: readlineDll.}
-# Bindable undo commands. 
-
-proc revert_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_revert_line", 
-    dynlib: readlineDll.}
-proc undo_command*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_undo_command", 
-    dynlib: readlineDll.}
-# Bindable tilde expansion commands. 
-
-proc tilde_expand*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tilde_expand", 
-    dynlib: readlineDll.}
-# Bindable terminal control commands. 
-
-proc restart_output*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_restart_output", dynlib: readlineDll.}
-proc stop_output*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_stop_output", 
-    dynlib: readlineDll.}
-# Miscellaneous bindable commands. 
-
-proc abort*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_abort", 
-                                       dynlib: readlineDll.}
-proc tty_status*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tty_status", 
-    dynlib: readlineDll.}
-# Bindable commands for incremental and non-incremental history searching. 
-
-proc history_search_forward*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_history_search_forward", dynlib: readlineDll.}
-proc history_search_backward*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_history_search_backward", dynlib: readlineDll.}
-proc noninc_forward_search*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_noninc_forward_search", dynlib: readlineDll.}
-proc noninc_reverse_search*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_noninc_reverse_search", dynlib: readlineDll.}
-proc noninc_forward_search_again*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_noninc_forward_search_again", dynlib: readlineDll.}
-proc noninc_reverse_search_again*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_noninc_reverse_search_again", dynlib: readlineDll.}
-# Bindable command used when inserting a matching close character. 
-
-proc insert_close*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_insert_close", 
-    dynlib: readlineDll.}
-# Not available unless READLINE_CALLBACKS is defined. 
-
-proc callback_handler_install*(a2: cstring, a3: TvcpFunc){.cdecl, 
-    importc: "rl_callback_handler_install", dynlib: readlineDll.}
-proc callback_read_char*(){.cdecl, importc: "rl_callback_read_char", 
-                            dynlib: readlineDll.}
-proc callback_handler_remove*(){.cdecl, importc: "rl_callback_handler_remove", 
-                                 dynlib: readlineDll.}
-# Things for vi mode. Not available unless readline is compiled -DVI_MODE. 
-# VI-mode bindable commands. 
-
-proc vi_redo*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_redo", 
-    dynlib: readlineDll.}
-proc vi_undo*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_undo", 
-    dynlib: readlineDll.}
-proc vi_yank_arg*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_yank_arg", 
-    dynlib: readlineDll.}
-proc vi_fetch_history*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_fetch_history", dynlib: readlineDll.}
-proc vi_search_again*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_search_again", dynlib: readlineDll.}
-proc vi_search*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_search", 
-    dynlib: readlineDll.}
-proc vi_complete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_complete", 
-    dynlib: readlineDll.}
-proc vi_tilde_expand*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_tilde_expand", dynlib: readlineDll.}
-proc vi_prev_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_prev_word", 
-    dynlib: readlineDll.}
-proc vi_next_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_next_word", 
-    dynlib: readlineDll.}
-proc vi_end_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_end_word", 
-    dynlib: readlineDll.}
-proc vi_insert_beg*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_insert_beg", dynlib: readlineDll.}
-proc vi_append_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_append_mode", dynlib: readlineDll.}
-proc vi_append_eol*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_append_eol", dynlib: readlineDll.}
-proc vi_eof_maybe*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eof_maybe", 
-    dynlib: readlineDll.}
-proc vi_insertion_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_insertion_mode", dynlib: readlineDll.}
-proc vi_insert_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_insert_mode", dynlib: readlineDll.}
-proc vi_movement_mode*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_movement_mode", dynlib: readlineDll.}
-proc vi_arg_digit*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_arg_digit", 
-    dynlib: readlineDll.}
-proc vi_change_case*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_change_case", dynlib: readlineDll.}
-proc vi_put*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_put", 
-                                        dynlib: readlineDll.}
-proc vi_column*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_column", 
-    dynlib: readlineDll.}
-proc vi_delete_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_delete_to", 
-    dynlib: readlineDll.}
-proc vi_change_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_change_to", 
-    dynlib: readlineDll.}
-proc vi_yank_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_yank_to", 
-    dynlib: readlineDll.}
-proc vi_rubout*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_rubout", 
-    dynlib: readlineDll.}
-proc vi_delete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_delete", 
-    dynlib: readlineDll.}
-proc vi_back_to_indent*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_back_to_indent", dynlib: readlineDll.}
-proc vi_first_print*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_first_print", dynlib: readlineDll.}
-proc vi_char_search*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_char_search", dynlib: readlineDll.}
-proc vi_match*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_match", 
-    dynlib: readlineDll.}
-proc vi_change_char*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_change_char", dynlib: readlineDll.}
-proc vi_subst*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_subst", 
-    dynlib: readlineDll.}
-proc vi_overstrike*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_overstrike", dynlib: readlineDll.}
-proc vi_overstrike_delete*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_vi_overstrike_delete", dynlib: readlineDll.}
-proc vi_replace*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_replace", 
-    dynlib: readlineDll.}
-proc vi_set_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_set_mark", 
-    dynlib: readlineDll.}
-proc vi_goto_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_goto_mark", 
-    dynlib: readlineDll.}
-# VI-mode utility functions. 
-
-proc vi_check*(): cint{.cdecl, importc: "rl_vi_check", dynlib: readlineDll.}
-proc vi_domove*(a2: cint, a3: ptr cint): cint{.cdecl, importc: "rl_vi_domove", 
-    dynlib: readlineDll.}
-proc vi_bracktype*(a2: cint): cint{.cdecl, importc: "rl_vi_bracktype", 
-                                    dynlib: readlineDll.}
-proc vi_start_inserting*(a2: cint, a3: cint, a4: cint){.cdecl, 
-    importc: "rl_vi_start_inserting", dynlib: readlineDll.}
-# VI-mode pseudo-bindable commands, used as utility functions. 
-
-proc vi_fXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_fWord", 
-    dynlib: readlineDll.}
-proc vi_bXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_bWord", 
-    dynlib: readlineDll.}
-proc vi_eXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eWord", 
-    dynlib: readlineDll.}
-proc vi_fword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_fword", 
-    dynlib: readlineDll.}
-proc vi_bword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_bword", 
-    dynlib: readlineDll.}
-proc vi_eword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eword", 
-    dynlib: readlineDll.}
-# **************************************************************** 
-#								    
-#			Well Published Functions		    
-#								    
-# **************************************************************** 
-# Readline functions. 
-# Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. 
-
-proc readline*(a2: cstring): cstring{.cdecl, importc: "readline", 
-                                      dynlib: readlineDll.}
-proc free*(mem: cstring) {.importc: "free", nodecl.}
-  ## free the buffer that `readline` returned.
-
-proc set_prompt*(a2: cstring): cint{.cdecl, importc: "rl_set_prompt", 
-                                     dynlib: readlineDll.}
-proc expand_prompt*(a2: cstring): cint{.cdecl, importc: "rl_expand_prompt", 
-                                        dynlib: readlineDll.}
-proc initialize*(): cint{.cdecl, importc: "rl_initialize", dynlib: readlineDll.}
-# Undocumented; unused by readline 
-
-proc discard_argument*(): cint{.cdecl, importc: "rl_discard_argument", 
-                                dynlib: readlineDll.}
-# Utility functions to bind keys to readline commands. 
-
-proc add_defun*(a2: cstring, a3: CommandFunc, a4: cint): cint{.cdecl, 
-    importc: "rl_add_defun", dynlib: readlineDll.}
-proc bind_key*(a2: cint, a3: CommandFunc): cint{.cdecl, 
-    importc: "rl_bind_key", dynlib: readlineDll.}
-proc bind_key_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.cdecl, 
-    importc: "rl_bind_key_in_map", dynlib: readlineDll.}
-proc unbind_key*(a2: cint): cint{.cdecl, importc: "rl_unbind_key", 
-                                  dynlib: readlineDll.}
-proc unbind_key_in_map*(a2: cint, a3: PKeymap): cint{.cdecl, 
-    importc: "rl_unbind_key_in_map", dynlib: readlineDll.}
-proc bind_key_if_unbound*(a2: cint, a3: CommandFunc): cint{.cdecl, 
-    importc: "rl_bind_key_if_unbound", dynlib: readlineDll.}
-proc bind_key_if_unbound_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.
-    cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.}
-proc unbind_function_in_map*(a2: CommandFunc, a3: PKeymap): cint{.cdecl, 
-    importc: "rl_unbind_function_in_map", dynlib: readlineDll.}
-proc unbind_command_in_map*(a2: cstring, a3: PKeymap): cint{.cdecl, 
-    importc: "rl_unbind_command_in_map", dynlib: readlineDll.}
-proc bind_keyseq*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
-    importc: "rl_bind_keyseq", dynlib: readlineDll.}
-proc bind_keyseq_in_map*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.
-    cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.}
-proc bind_keyseq_if_unbound*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
-    importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.}
-proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: CommandFunc, 
-                                    a4: PKeymap): cint{.cdecl, 
-    importc: "rl_bind_keyseq_if_unbound_in_map", dynlib: readlineDll.}
-proc generic_bind*(a2: cint, a3: cstring, a4: cstring, a5: PKeymap): cint{.
-    cdecl, importc: "rl_generic_bind", dynlib: readlineDll.}
-proc variable_value*(a2: cstring): cstring{.cdecl, importc: "rl_variable_value", 
-    dynlib: readlineDll.}
-proc variable_bind*(a2: cstring, a3: cstring): cint{.cdecl, 
-    importc: "rl_variable_bind", dynlib: readlineDll.}
-# Backwards compatibility, use rl_bind_keyseq_in_map instead. 
-
-proc set_key*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.cdecl, 
-    importc: "rl_set_key", dynlib: readlineDll.}
-# Backwards compatibility, use rl_generic_bind instead. 
-
-proc macro_bind*(a2: cstring, a3: cstring, a4: PKeymap): cint{.cdecl, 
-    importc: "rl_macro_bind", dynlib: readlineDll.}
-# Undocumented in the texinfo manual; not really useful to programs. 
-
-proc translate_keyseq*(a2: cstring, a3: cstring, a4: ptr cint): cint{.cdecl, 
-    importc: "rl_translate_keyseq", dynlib: readlineDll.}
-proc untranslate_keyseq*(a2: cint): cstring{.cdecl, 
-    importc: "rl_untranslate_keyseq", dynlib: readlineDll.}
-proc named_function*(a2: cstring): CommandFunc{.cdecl, 
-    importc: "rl_named_function", dynlib: readlineDll.}
-proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): CommandFunc{.
-    cdecl, importc: "rl_function_of_keyseq", dynlib: readlineDll.}
-proc list_funmap_names*(){.cdecl, importc: "rl_list_funmap_names", 
-                           dynlib: readlineDll.}
-proc invoking_keyseqs_in_map*(a2: CommandFunc, a3: PKeymap): cstringArray{.
-    cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.}
-proc invoking_keyseqs*(a2: CommandFunc): cstringArray{.cdecl, 
-    importc: "rl_invoking_keyseqs", dynlib: readlineDll.}
-proc function_dumper*(a2: cint){.cdecl, importc: "rl_function_dumper", 
-                                 dynlib: readlineDll.}
-proc macro_dumper*(a2: cint){.cdecl, importc: "rl_macro_dumper", 
-                              dynlib: readlineDll.}
-proc variable_dumper*(a2: cint){.cdecl, importc: "rl_variable_dumper", 
-                                 dynlib: readlineDll.}
-proc read_init_file*(a2: cstring): cint{.cdecl, importc: "rl_read_init_file", 
-    dynlib: readlineDll.}
-proc parse_and_bind*(a2: cstring): cint{.cdecl, importc: "rl_parse_and_bind", 
-    dynlib: readlineDll.}
-
-proc get_keymap_name*(a2: PKeymap): cstring{.cdecl, 
-    importc: "rl_get_keymap_name", dynlib: readlineDll.}
-
-proc set_keymap_from_edit_mode*(){.cdecl, 
-                                   importc: "rl_set_keymap_from_edit_mode", 
-                                   dynlib: readlineDll.}
-proc get_keymap_name_from_edit_mode*(): cstring{.cdecl, 
-    importc: "rl_get_keymap_name_from_edit_mode", dynlib: readlineDll.}
-# Functions for manipulating the funmap, which maps command names to functions. 
-
-proc add_funmap_entry*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
-    importc: "rl_add_funmap_entry", dynlib: readlineDll.}
-proc funmap_names*(): cstringArray{.cdecl, importc: "rl_funmap_names", 
-                                    dynlib: readlineDll.}
-# Undocumented, only used internally -- there is only one funmap, and this
-#   function may be called only once. 
-
-proc initialize_funmap*(){.cdecl, importc: "rl_initialize_funmap", 
-                           dynlib: readlineDll.}
-# Utility functions for managing keyboard macros. 
-
-proc push_macro_input*(a2: cstring){.cdecl, importc: "rl_push_macro_input", 
-                                     dynlib: readlineDll.}
-# Functions for undoing, from undo.c 
-
-proc add_undo*(a2: Undo_code, a3: cint, a4: cint, a5: cstring){.cdecl, 
-    importc: "rl_add_undo", dynlib: readlineDll.}
-proc free_undo_list*(){.cdecl, importc: "rl_free_undo_list", dynlib: readlineDll.}
-proc do_undo*(): cint{.cdecl, importc: "rl_do_undo", dynlib: readlineDll.}
-proc begin_undo_group*(): cint{.cdecl, importc: "rl_begin_undo_group", 
-                                dynlib: readlineDll.}
-proc end_undo_group*(): cint{.cdecl, importc: "rl_end_undo_group", 
-                              dynlib: readlineDll.}
-proc modifying*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_modifying", 
-    dynlib: readlineDll.}
-# Functions for redisplay. 
-
-proc redisplay*(){.cdecl, importc: "rl_redisplay", dynlib: readlineDll.}
-proc on_new_line*(): cint{.cdecl, importc: "rl_on_new_line", dynlib: readlineDll.}
-proc on_new_line_with_prompt*(): cint{.cdecl, 
-                                       importc: "rl_on_new_line_with_prompt", 
-                                       dynlib: readlineDll.}
-proc forced_update_display*(): cint{.cdecl, importc: "rl_forced_update_display", 
-                                     dynlib: readlineDll.}
-proc clear_message*(): cint{.cdecl, importc: "rl_clear_message", 
-                             dynlib: readlineDll.}
-proc reset_line_state*(): cint{.cdecl, importc: "rl_reset_line_state", 
-                                dynlib: readlineDll.}
-proc crlf*(): cint{.cdecl, importc: "rl_crlf", dynlib: readlineDll.}
-proc message*(a2: cstring): cint{.varargs, cdecl, importc: "rl_message", 
-                                  dynlib: readlineDll.}
-proc show_char*(a2: cint): cint{.cdecl, importc: "rl_show_char", 
-                                 dynlib: readlineDll.}
-# Undocumented in texinfo manual. 
-
-proc character_len*(a2: cint, a3: cint): cint{.cdecl, 
-    importc: "rl_character_len", dynlib: readlineDll.}
-# Save and restore internal prompt redisplay information. 
-
-proc save_prompt*(){.cdecl, importc: "rl_save_prompt", dynlib: readlineDll.}
-proc restore_prompt*(){.cdecl, importc: "rl_restore_prompt", dynlib: readlineDll.}
-# Modifying text. 
-
-proc replace_line*(a2: cstring, a3: cint){.cdecl, importc: "rl_replace_line", 
-    dynlib: readlineDll.}
-proc insert_text*(a2: cstring): cint{.cdecl, importc: "rl_insert_text", 
-                                      dynlib: readlineDll.}
-proc delete_text*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_delete_text", 
-    dynlib: readlineDll.}
-proc kill_text*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_text", 
-    dynlib: readlineDll.}
-proc copy_text*(a2: cint, a3: cint): cstring{.cdecl, importc: "rl_copy_text", 
-    dynlib: readlineDll.}
-# Terminal and tty mode management. 
-
-proc prep_terminal*(a2: cint){.cdecl, importc: "rl_prep_terminal", 
-                               dynlib: readlineDll.}
-proc deprep_terminal*(){.cdecl, importc: "rl_deprep_terminal", 
-                         dynlib: readlineDll.}
-proc tty_set_default_bindings*(a2: PKeymap){.cdecl, 
-    importc: "rl_tty_set_default_bindings", dynlib: readlineDll.}
-proc tty_unset_default_bindings*(a2: PKeymap){.cdecl, 
-    importc: "rl_tty_unset_default_bindings", dynlib: readlineDll.}
-proc reset_terminal*(a2: cstring): cint{.cdecl, importc: "rl_reset_terminal", 
-    dynlib: readlineDll.}
-proc resize_terminal*(){.cdecl, importc: "rl_resize_terminal", 
-                         dynlib: readlineDll.}
-proc set_screen_size*(a2: cint, a3: cint){.cdecl, importc: "rl_set_screen_size", 
-    dynlib: readlineDll.}
-proc get_screen_size*(a2: ptr cint, a3: ptr cint){.cdecl, 
-    importc: "rl_get_screen_size", dynlib: readlineDll.}
-proc reset_screen_size*(){.cdecl, importc: "rl_reset_screen_size", 
-                           dynlib: readlineDll.}
-proc get_termcap*(a2: cstring): cstring{.cdecl, importc: "rl_get_termcap", 
-    dynlib: readlineDll.}
-# Functions for character input. 
-
-proc stuff_char*(a2: cint): cint{.cdecl, importc: "rl_stuff_char", 
-                                  dynlib: readlineDll.}
-proc execute_next*(a2: cint): cint{.cdecl, importc: "rl_execute_next", 
-                                    dynlib: readlineDll.}
-proc clear_pending_input*(): cint{.cdecl, importc: "rl_clear_pending_input", 
-                                   dynlib: readlineDll.}
-proc read_key*(): cint{.cdecl, importc: "rl_read_key", dynlib: readlineDll.}
-proc getc*(a2: File): cint{.cdecl, importc: "rl_getc", dynlib: readlineDll.}
-proc set_keyboard_input_timeout*(a2: cint): cint{.cdecl, 
-    importc: "rl_set_keyboard_input_timeout", dynlib: readlineDll.}
-# `Public' utility functions . 
-
-proc extend_line_buffer*(a2: cint){.cdecl, importc: "rl_extend_line_buffer", 
-                                    dynlib: readlineDll.}
-proc ding*(): cint{.cdecl, importc: "rl_ding", dynlib: readlineDll.}
-proc alphabetic*(a2: cint): cint{.cdecl, importc: "rl_alphabetic", 
-                                  dynlib: readlineDll.}
-proc free*(a2: pointer){.cdecl, importc: "rl_free", dynlib: readlineDll.}
-# Readline signal handling, from signals.c 
-
-proc set_signals*(): cint{.cdecl, importc: "rl_set_signals", dynlib: readlineDll.}
-proc clear_signals*(): cint{.cdecl, importc: "rl_clear_signals", 
-                             dynlib: readlineDll.}
-proc cleanup_after_signal*(){.cdecl, importc: "rl_cleanup_after_signal", 
-                              dynlib: readlineDll.}
-proc reset_after_signal*(){.cdecl, importc: "rl_reset_after_signal", 
-                            dynlib: readlineDll.}
-proc free_line_state*(){.cdecl, importc: "rl_free_line_state", 
-                         dynlib: readlineDll.}
-proc echo_signal_char*(a2: cint){.cdecl, importc: "rl_echo_signal_char", 
-                                  dynlib: readlineDll.}
-proc set_paren_blink_timeout*(a2: cint): cint{.cdecl, 
-    importc: "rl_set_paren_blink_timeout", dynlib: readlineDll.}
-# Undocumented. 
-
-proc maybe_save_line*(): cint{.cdecl, importc: "rl_maybe_save_line", 
-                               dynlib: readlineDll.}
-proc maybe_unsave_line*(): cint{.cdecl, importc: "rl_maybe_unsave_line", 
-                                 dynlib: readlineDll.}
-proc maybe_replace_line*(): cint{.cdecl, importc: "rl_maybe_replace_line", 
-                                  dynlib: readlineDll.}
-# Completion functions. 
-
-proc complete_internal*(a2: cint): cint{.cdecl, importc: "rl_complete_internal", 
-    dynlib: readlineDll.}
-proc display_match_list*(a2: cstringArray, a3: cint, a4: cint){.cdecl, 
-    importc: "rl_display_match_list", dynlib: readlineDll.}
-proc completion_matches*(a2: cstring, a3: Compentry_func): cstringArray{.
-    cdecl, importc: "rl_completion_matches", dynlib: readlineDll.}
-proc username_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, 
-    importc: "rl_username_completion_function", dynlib: readlineDll.}
-proc filename_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, 
-    importc: "rl_filename_completion_function", dynlib: readlineDll.}
-proc completion_mode*(a2: CommandFunc): cint{.cdecl, 
-    importc: "rl_completion_mode", dynlib: readlineDll.}
-# **************************************************************** 
-#								    
-#			Well Published Variables		    
-#								    
-# **************************************************************** 
-
-when false: 
-  # The version of this incarnation of the readline library. 
-  var library_version*{.importc: "rl_library_version", dynlib: readlineDll.}: cstring
-  # e.g., "4.2" 
-  var readline_version*{.importc: "rl_readline_version", dynlib: readlineDll.}: cint
-  # e.g., 0x0402 
-  # True if this is real GNU readline. 
-  var gnu_readline_p*{.importc: "rl_gnu_readline_p", dynlib: readlineDll.}: cint
-  # Flags word encapsulating the current readline state. 
-  var readline_state*{.importc: "rl_readline_state", dynlib: readlineDll.}: cint
-  # Says which editing mode readline is currently using.  1 means emacs mode;
-  #   0 means vi mode. 
-  var editing_mode*{.importc: "rl_editing_mode", dynlib: readlineDll.}: cint
-  # Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
-  #   overwrite mode.  Reset to insert mode on each input line. 
-  var insert_mode*{.importc: "rl_insert_mode", dynlib: readlineDll.}: cint
-  # The name of the calling program.  You should initialize this to
-  #   whatever was in argv[0].  It is used when parsing conditionals. 
-  var readline_name*{.importc: "rl_readline_name", dynlib: readlineDll.}: cstring
-  # The prompt readline uses.  This is set from the argument to
-  #   readline (), and should not be assigned to directly. 
-  var prompt*{.importc: "rl_prompt", dynlib: readlineDll.}: cstring
-  # The prompt string that is actually displayed by rl_redisplay.  Public so
-  #   applications can more easily supply their own redisplay functions. 
-  var display_prompt*{.importc: "rl_display_prompt", dynlib: readlineDll.}: cstring
-  # The line buffer that is in use. 
-  var line_buffer*{.importc: "rl_line_buffer", dynlib: readlineDll.}: cstring
-  # The location of point, and end. 
-  var point*{.importc: "rl_point", dynlib: readlineDll.}: cint
-  var theEnd*{.importc: "rl_end", dynlib: readlineDll.}: cint
-  # The mark, or saved cursor position. 
-  var mark*{.importc: "rl_mark", dynlib: readlineDll.}: cint
-  # Flag to indicate that readline has finished with the current input
-  #   line and should return it. 
-  var done*{.importc: "rl_done", dynlib: readlineDll.}: cint
-  # If set to a character value, that will be the next keystroke read. 
-  var pending_input*{.importc: "rl_pending_input", dynlib: readlineDll.}: cint
-  # Non-zero if we called this function from _rl_dispatch().  It's present
-  #   so functions can find out whether they were called from a key binding
-  #   or directly from an application. 
-  var dispatching*{.importc: "rl_dispatching", dynlib: readlineDll.}: cint
-  # Non-zero if the user typed a numeric argument before executing the
-  #   current function. 
-  var explicit_arg*{.importc: "rl_explicit_arg", dynlib: readlineDll.}: cint
-  # The current value of the numeric argument specified by the user. 
-  var numeric_arg*{.importc: "rl_numeric_arg", dynlib: readlineDll.}: cint
-  # The address of the last command function Readline executed. 
-  var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: CommandFunc
-  # The name of the terminal to use. 
-  var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring
-  # The input and output streams. 
-  var instream*{.importc: "rl_instream", dynlib: readlineDll.}: File
-  var outstream*{.importc: "rl_outstream", dynlib: readlineDll.}: File
-  # If non-zero, Readline gives values of LINES and COLUMNS from the environment
-  #   greater precedence than values fetched from the kernel when computing the
-  #   screen dimensions. 
-  var prefer_env_winsize*{.importc: "rl_prefer_env_winsize", dynlib: readlineDll.}: cint
-  # If non-zero, then this is the address of a function to call just
-  #   before readline_internal () prints the first prompt. 
-  var startup_hook*{.importc: "rl_startup_hook", dynlib: readlineDll.}:  hook_func
-  # If non-zero, this is the address of a function to call just before
-  #   readline_internal_setup () returns and readline_internal starts
-  #   reading input characters. 
-  var pre_input_hook*{.importc: "rl_pre_input_hook", dynlib: readlineDll.}: hook_func
-  # The address of a function to call periodically while Readline is
-  #   awaiting character input, or NULL, for no event handling. 
-  var event_hook*{.importc: "rl_event_hook", dynlib: readlineDll.}: hook_func
-  # The address of the function to call to fetch a character from the current
-  #   Readline input stream 
-  var getc_function*{.importc: "rl_getc_function", dynlib: readlineDll.}: getc_func
-  var redisplay_function*{.importc: "rl_redisplay_function", dynlib: readlineDll.}: voidfunc
-  var prep_term_function*{.importc: "rl_prep_term_function", dynlib: readlineDll.}: vintfunc
-  var deprep_term_function*{.importc: "rl_deprep_term_function", 
-                             dynlib: readlineDll.}: voidfunc
-  # Dispatch variables. 
-  var executing_keymap*{.importc: "rl_executing_keymap", dynlib: readlineDll.}: PKeymap
-  var binding_keymap*{.importc: "rl_binding_keymap", dynlib: readlineDll.}: PKeymap
-  # Display variables. 
-  # If non-zero, readline will erase the entire line, including any prompt,
-  #   if the only thing typed on an otherwise-blank line is something bound to
-  #   rl_newline. 
-  var erase_empty_line*{.importc: "rl_erase_empty_line", dynlib: readlineDll.}: cint
-  # If non-zero, the application has already printed the prompt (rl_prompt)
-  #   before calling readline, so readline should not output it the first time
-  #   redisplay is done. 
-  var already_prompted*{.importc: "rl_already_prompted", dynlib: readlineDll.}: cint
-  # A non-zero value means to read only this many characters rather than
-  #   up to a character bound to accept-line. 
-  var num_chars_to_read*{.importc: "rl_num_chars_to_read", dynlib: readlineDll.}: cint
-  # The text of a currently-executing keyboard macro. 
-  var executing_macro*{.importc: "rl_executing_macro", dynlib: readlineDll.}: cstring
-  # Variables to control readline signal handling. 
-  # If non-zero, readline will install its own signal handlers for
-  #   SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. 
-  var catch_signals*{.importc: "rl_catch_signals", dynlib: readlineDll.}: cint
-  # If non-zero, readline will install a signal handler for SIGWINCH
-  #   that also attempts to call any calling application's SIGWINCH signal
-  #   handler.  Note that the terminal is not cleaned up before the
-  #   application's signal handler is called; use rl_cleanup_after_signal()
-  #   to do that. 
-  var catch_sigwinch*{.importc: "rl_catch_sigwinch", dynlib: readlineDll.}: cint
-  # Completion variables. 
-  # Pointer to the generator function for completion_matches ().
-  #   NULL means to use rl_filename_completion_function (), the default
-  #   filename completer. 
-  var completion_entry_function*{.importc: "rl_completion_entry_function", 
-                                  dynlib: readlineDll.}: compentry_func
-  # Optional generator for menu completion.  Default is
-  #   rl_completion_entry_function (rl_filename_completion_function). 
-  var menu_completion_entry_function*{.importc: "rl_menu_completion_entry_function", 
-                                       dynlib: readlineDll.}: compentry_func
-  # If rl_ignore_some_completions_function is non-NULL it is the address
-  #   of a function to call after all of the possible matches have been
-  #   generated, but before the actual completion is done to the input line.
-  #   The function is called with one argument; a NULL terminated array
-  #   of (char *).  If your function removes any of the elements, they
-  #   must be free()'ed. 
-  var ignore_some_completions_function*{.
-      importc: "rl_ignore_some_completions_function", dynlib: readlineDll.}: compignore_func
-  # Pointer to alternative function to create matches.
-  #   Function is called with TEXT, START, and END.
-  #   START and END are indices in RL_LINE_BUFFER saying what the boundaries
-  #   of TEXT are.
-  #   If this function exists and returns NULL then call the value of
-  #   rl_completion_entry_function to try to match, otherwise use the
-  #   array of strings returned. 
-  var attempted_completion_function*{.importc: "rl_attempted_completion_function", 
-                                      dynlib: readlineDll.}: completion_func
-  # The basic list of characters that signal a break between words for the
-  #   completer routine.  The initial contents of this variable is what
-  #   breaks words in the shell, i.e. "n\"\\'`@$>". 
-  var basic_word_break_characters*{.importc: "rl_basic_word_break_characters", 
-                                    dynlib: readlineDll.}: cstring
-  # The list of characters that signal a break between words for
-  #   rl_complete_internal.  The default list is the contents of
-  #   rl_basic_word_break_characters.  
-  var completer_word_break_characters*{.importc: "rl_completer_word_break_characters", 
-                                        dynlib: readlineDll.}: cstring
-  # Hook function to allow an application to set the completion word
-  #   break characters before readline breaks up the line.  Allows
-  #   position-dependent word break characters. 
-  var completion_word_break_hook*{.importc: "rl_completion_word_break_hook", 
-                                   dynlib: readlineDll.}: cpvfunc
-  # List of characters which can be used to quote a substring of the line.
-  #   Completion occurs on the entire substring, and within the substring   
-  #   rl_completer_word_break_characters are treated as any other character,
-  #   unless they also appear within this list. 
-  var completer_quote_characters*{.importc: "rl_completer_quote_characters", 
-                                   dynlib: readlineDll.}: cstring
-  # List of quote characters which cause a word break. 
-  var basic_quote_characters*{.importc: "rl_basic_quote_characters", 
-                               dynlib: readlineDll.}: cstring
-  # List of characters that need to be quoted in filenames by the completer. 
-  var filename_quote_characters*{.importc: "rl_filename_quote_characters", 
-                                  dynlib: readlineDll.}: cstring
-  # List of characters that are word break characters, but should be left
-  #   in TEXT when it is passed to the completion function.  The shell uses
-  #   this to help determine what kind of completing to do. 
-  var special_prefixes*{.importc: "rl_special_prefixes", dynlib: readlineDll.}: cstring
-  # If non-zero, then this is the address of a function to call when
-  #   completing on a directory name.  The function is called with
-  #   the address of a string (the current directory name) as an arg.  It
-  #   changes what is displayed when the possible completions are printed
-  #   or inserted. 
-  var directory_completion_hook*{.importc: "rl_directory_completion_hook", 
-                                  dynlib: readlineDll.}: icppfunc
-  # If non-zero, this is the address of a function to call when completing
-  #   a directory name.  This function takes the address of the directory name
-  #   to be modified as an argument.  Unlike rl_directory_completion_hook, it
-  #   only modifies the directory name used in opendir(2), not what is displayed
-  #   when the possible completions are printed or inserted.  It is called
-  #   before rl_directory_completion_hook.  I'm not happy with how this works
-  #   yet, so it's undocumented. 
-  var directory_rewrite_hook*{.importc: "rl_directory_rewrite_hook", 
-                               dynlib: readlineDll.}: icppfunc
-  # If non-zero, this is the address of a function to call when reading
-  #   directory entries from the filesystem for completion and comparing
-  #   them to the partial word to be completed.  The function should
-  #   either return its first argument (if no conversion takes place) or
-  #   newly-allocated memory.  This can, for instance, convert filenames
-  #   between character sets for comparison against what's typed at the
-  #   keyboard.  The returned value is what is added to the list of
-  #   matches.  The second argument is the length of the filename to be
-  #   converted. 
-  var filename_rewrite_hook*{.importc: "rl_filename_rewrite_hook", 
-                              dynlib: readlineDll.}: dequote_func
-  # If non-zero, then this is the address of a function to call when
-  #   completing a word would normally display the list of possible matches.
-  #   This function is called instead of actually doing the display.
-  #   It takes three arguments: (char **matches, int num_matches, int max_length)
-  #   where MATCHES is the array of strings that matched, NUM_MATCHES is the
-  #   number of strings in that array, and MAX_LENGTH is the length of the
-  #   longest string in that array. 
-  var completion_display_matches_hook*{.importc: "rl_completion_display_matches_hook", 
-                                        dynlib: readlineDll.}: compdisp_func
-  # Non-zero means that the results of the matches are to be treated
-  #   as filenames.  This is ALWAYS zero on entry, and can only be changed
-  #   within a completion entry finder function. 
-  var filename_completion_desired*{.importc: "rl_filename_completion_desired", 
-                                    dynlib: readlineDll.}: cint
-  # Non-zero means that the results of the matches are to be quoted using
-  #   double quotes (or an application-specific quoting mechanism) if the
-  #   filename contains any characters in rl_word_break_chars.  This is
-  #   ALWAYS non-zero on entry, and can only be changed within a completion
-  #   entry finder function. 
-  var filename_quoting_desired*{.importc: "rl_filename_quoting_desired", 
-                                 dynlib: readlineDll.}: cint
-  # Set to a function to quote a filename in an application-specific fashion.
-  #   Called with the text to quote, the type of match found (single or multiple)
-  #   and a pointer to the quoting character to be used, which the function can
-  #   reset if desired. 
-  var filename_quoting_function*{.importc: "rl_filename_quoting_function", 
-                                  dynlib: readlineDll.}: quote_func
-  # Function to call to remove quoting characters from a filename.  Called
-  #   before completion is attempted, so the embedded quotes do not interfere
-  #   with matching names in the file system. 
-  var filename_dequoting_function*{.importc: "rl_filename_dequoting_function", 
-                                    dynlib: readlineDll.}: dequote_func
-  # Function to call to decide whether or not a word break character is
-  #   quoted.  If a character is quoted, it does not break words for the
-  #   completer. 
-  var char_is_quoted_p*{.importc: "rl_char_is_quoted_p", dynlib: readlineDll.}: linebuf_func
-  # Non-zero means to suppress normal filename completion after the
-  #   user-specified completion function has been called. 
-  var attempted_completion_over*{.importc: "rl_attempted_completion_over", 
-                                  dynlib: readlineDll.}: cint
-  # Set to a character describing the type of completion being attempted by
-  #   rl_complete_internal; available for use by application completion
-  #   functions. 
-  var completion_type*{.importc: "rl_completion_type", dynlib: readlineDll.}: cint
-  # Set to the last key used to invoke one of the completion functions 
-  var completion_invoking_key*{.importc: "rl_completion_invoking_key", 
-                                dynlib: readlineDll.}: cint
-  # Up to this many items will be displayed in response to a
-  #   possible-completions call.  After that, we ask the user if she
-  #   is sure she wants to see them all.  The default value is 100. 
-  var completion_query_items*{.importc: "rl_completion_query_items", 
-                               dynlib: readlineDll.}: cint
-  # Character appended to completed words when at the end of the line.  The
-  #   default is a space.  Nothing is added if this is '\0'. 
-  var completion_append_character*{.importc: "rl_completion_append_character", 
-                                    dynlib: readlineDll.}: cint
-  # If set to non-zero by an application completion function,
-  #   rl_completion_append_character will not be appended. 
-  var completion_suppress_append*{.importc: "rl_completion_suppress_append", 
-                                   dynlib: readlineDll.}: cint
-  # Set to any quote character readline thinks it finds before any application
-  #   completion function is called. 
-  var completion_quote_character*{.importc: "rl_completion_quote_character", 
-                                   dynlib: readlineDll.}: cint
-  # Set to a non-zero value if readline found quoting anywhere in the word to
-  #   be completed; set before any application completion function is called. 
-  var completion_found_quote*{.importc: "rl_completion_found_quote", 
-                               dynlib: readlineDll.}: cint
-  # If non-zero, the completion functions don't append any closing quote.
-  #   This is set to 0 by rl_complete_internal and may be changed by an
-  #   application-specific completion function. 
-  var completion_suppress_quote*{.importc: "rl_completion_suppress_quote", 
-                                  dynlib: readlineDll.}: cint
-  # If non-zero, readline will sort the completion matches.  On by default. 
-  var sort_completion_matches*{.importc: "rl_sort_completion_matches", 
-                                dynlib: readlineDll.}: cint
-  # If non-zero, a slash will be appended to completed filenames that are
-  #   symbolic links to directory names, subject to the value of the
-  #   mark-directories variable (which is user-settable).  This exists so
-  #   that application completion functions can override the user's preference
-  #   (set via the mark-symlinked-directories variable) if appropriate.
-  #   It's set to the value of _rl_complete_mark_symlink_dirs in
-  #   rl_complete_internal before any application-specific completion
-  #   function is called, so without that function doing anything, the user's
-  #   preferences are honored. 
-  var completion_mark_symlink_dirs*{.importc: "rl_completion_mark_symlink_dirs", 
-                                     dynlib: readlineDll.}: cint
-  # If non-zero, then disallow duplicates in the matches. 
-  var ignore_completion_duplicates*{.importc: "rl_ignore_completion_duplicates", 
-                                     dynlib: readlineDll.}: cint
-  # If this is non-zero, completion is (temporarily) inhibited, and the
-  #   completion character will be inserted as any other. 
-  var inhibit_completion*{.importc: "rl_inhibit_completion", dynlib: readlineDll.}: cint
-# Input error; can be returned by (*rl_getc_function) if readline is reading
-#   a top-level command (RL_ISSTATE (RL_STATE_READCMD)). 
-
-const 
-  READERR* = (- 2)
-
-# Definitions available for use by readline clients. 
-
-const 
-  PROMPT_START_IGNORE* = '\x01'
-  PROMPT_END_IGNORE* = '\x02'
-
-# Possible values for do_replace argument to rl_filename_quoting_function,
-#   called by rl_complete_internal. 
-
-const 
-  NO_MATCH* = 0
-  SINGLE_MATCH* = 1
-  MULT_MATCH* = 2
-
-# Possible state values for rl_readline_state 
-
-const 
-  STATE_NONE* = 0x00000000    # no state; before first call 
-  STATE_INITIALIZING* = 0x00000001 # initializing 
-  STATE_INITIALIZED* = 0x00000002 # initialization done 
-  STATE_TERMPREPPED* = 0x00000004 # terminal is prepped 
-  STATE_READCMD* = 0x00000008 # reading a command key 
-  STATE_METANEXT* = 0x00000010 # reading input after ESC 
-  STATE_DISPATCHING* = 0x00000020 # dispatching to a command 
-  STATE_MOREINPUT* = 0x00000040 # reading more input in a command function 
-  STATE_ISEARCH* = 0x00000080 # doing incremental search 
-  STATE_NSEARCH* = 0x00000100 # doing non-inc search 
-  STATE_SEARCH* = 0x00000200  # doing a history search 
-  STATE_NUMERICARG* = 0x00000400 # reading numeric argument 
-  STATE_MACROINPUT* = 0x00000800 # getting input from a macro 
-  STATE_MACRODEF* = 0x00001000 # defining keyboard macro 
-  STATE_OVERWRITE* = 0x00002000 # overwrite mode 
-  STATE_COMPLETING* = 0x00004000 # doing completion 
-  STATE_SIGHANDLER* = 0x00008000 # in readline sighandler 
-  STATE_UNDOING* = 0x00010000 # doing an undo 
-  STATE_INPUTPENDING* = 0x00020000 # rl_execute_next called 
-  STATE_TTYCSAVED* = 0x00040000 # tty special chars saved 
-  STATE_CALLBACK* = 0x00080000 # using the callback interface 
-  STATE_VIMOTION* = 0x00100000 # reading vi motion arg 
-  STATE_MULTIKEY* = 0x00200000 # reading multiple-key command 
-  STATE_VICMDONCE* = 0x00400000 # entered vi command mode at least once 
-  STATE_REDISPLAYING* = 0x00800000 # updating terminal display 
-  STATE_DONE* = 0x01000000    # done; accepted line 
-
-template SETSTATE*(x: expr): stmt = 
-  readline_state = readline_state or (x)
-
-template UNSETSTATE*(x: expr): stmt = 
-  readline_state = readline_state and not (x)
-
-template ISSTATE*(x: expr): expr = 
-  (readline_state and x) != 0
-
-type 
-  Readline_state*{.pure, final.} = object 
-    point*: cint              # line state 
-    theEnd*: cint
-    mark*: cint
-    buffer*: cstring
-    buflen*: cint
-    ul*: ptr UNDO_LIST
-    prompt*: cstring          # global state 
-    rlstate*: cint
-    done*: cint
-    kmap*: PKeymap            # input state 
-    lastfunc*: CommandFunc
-    insmode*: cint
-    edmode*: cint
-    kseqlen*: cint
-    inf*: File
-    outf*: File
-    pendingin*: cint
-    theMacro*: cstring        # signal state 
-    catchsigs*: cint
-    catchsigwinch*: cint      # search state 
-                              # completion state 
-                              # options state 
-                              # reserved for future expansion, so the struct size doesn't change 
-    reserved*: array[0..64 - 1, char]
-{.deprecated: [Treadline_state: Readline_state].}
-
-
-proc save_state*(a2: ptr Readline_state): cint{.cdecl, 
-    importc: "rl_save_state", dynlib: readlineDll.}
-proc restore_state*(a2: ptr Readline_state): cint{.cdecl, 
-    importc: "rl_restore_state", dynlib: readlineDll.}
diff --git a/lib/wrappers/readline/rltypedefs.nim b/lib/wrappers/readline/rltypedefs.nim
deleted file mode 100644
index 759b81297..000000000
--- a/lib/wrappers/readline/rltypedefs.nim
+++ /dev/null
@@ -1,79 +0,0 @@
-# rltypedefs.h -- Type declarations for readline functions. 
-# Copyright (C) 2000-2009 Free Software Foundation, Inc.
-#
-#   This file is part of the GNU Readline Library (Readline), a library
-#   for reading lines of text with interactive input and history editing.      
-#
-#   Readline is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   Readline is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-type 
-  Function* = proc (): cint{.cdecl.}
-  VFunction* = proc (){.cdecl.}
-  CPFunction* = proc (): cstring{.cdecl.}
-  CPPFunction* = proc (): cstringArray{.cdecl.}
-{.deprecated: [TFunction: Function, TVFunction: VFunction,
-              TCPFunction: CPFunction, TCPPFunction: CPPFunction].}
-
-# Bindable functions 
-
-type 
-  Command_func* = proc (a2: cint, a3: cint): cint{.cdecl.}
-{.deprecated: [Tcommand_func: Command_func].}
-
-# Typedefs for the completion system 
-
-type 
-  Compentry_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.}
-  Completion_func* = proc (a2: cstring, a3: cint, a4: cint): cstringArray{.
-      cdecl.}
-  Quote_func* = proc (a2: cstring, a3: cint, a4: cstring): cstring{.cdecl.}
-  Dequote_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.}
-  Compignore_func* = proc (a2: cstringArray): cint{.cdecl.}
-  Compdisp_func* = proc (a2: cstringArray, a3: cint, a4: cint){.cdecl.}
-{.deprecated: [Tcompentry_func: Compentry_func,Tcompletion_func: Completion_func,
-              Tquote_func: Quote_func, Tdequote_func: Dequote_func,
-              Tcompignore_func: Compignore_func, Tcompdisp_func: Compdisp_func].}
-# Type for input and pre-read hook functions like rl_event_hook 
-
-type 
-  Thook_func* = proc (): cint{.cdecl.}
-
-# Input function type 
-
-type 
-  Tgetc_func* = proc (a2: File): cint{.cdecl.}
-
-# Generic function that takes a character buffer (which could be the readline
-#   line buffer) and an index into it (which could be rl_point) and returns
-#   an int. 
-
-type 
-  Tlinebuf_func* = proc (a2: cstring, a3: cint): cint{.cdecl.}
-
-# `Generic' function pointer typedefs 
-
-type 
-  Tintfunc* = proc (a2: cint): cint{.cdecl.}
-  Tivoidfunc* = proc (): cint{.cdecl.}
-  Ticpfunc* = proc (a2: cstring): cint{.cdecl.}
-  Ticppfunc* = proc (a2: cstringArray): cint{.cdecl.}
-  Tvoidfunc* = proc (){.cdecl.}
-  Tvintfunc* = proc (a2: cint){.cdecl.}
-  Tvcpfunc* = proc (a2: cstring){.cdecl.}
-  Tvcppfunc* = proc (a2: cstringArray){.cdecl.}
-  Tcpvfunc* = proc (): cstring{.cdecl.}
-  Tcpifunc* = proc (a2: cint): cstring{.cdecl.}
-  Tcpcpfunc* = proc (a2: cstring): cstring{.cdecl.}
-  Tcpcppfunc* = proc (a2: cstringArray): cstring{.cdecl.}
diff --git a/lib/wrappers/readline/tweaked/history.h b/lib/wrappers/readline/tweaked/history.h
deleted file mode 100644
index b79123790..000000000
--- a/lib/wrappers/readline/tweaked/history.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/* history.h -- the names of functions that you can call in history. */
-
-/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
-
-   This file contains the GNU History Library (History), a set of
-   routines for managing the text of previously typed lines.
-
-   History is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   History is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with History.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef C2NIM
-#  private historyDll
-#  dynlib historyDll
-#  cdecl
-#  if defined(windows)
-#    define historyDll "history.dll"
-#  elif defined(macosx)
-#    define historyDll "libhistory.dynlib"
-#  else
-#    define historyDll "libhistory.so.6(|.0)"
-#  endif
-#  prefix rl_
-#  prefix RL_
-#  suffix _t
-#  typeprefixes
-#  def PARAMS(x) x
-#  def time_t TTime
-#endif
-
-#  include "times"
-#  include "rltypedefs.h"
-
-typedef void *histdata_t;
-
-/* The structure used to store a history entry. */
-typedef struct _hist_entry {
-  char *line;
-  char *timestamp;		/* char * rather than time_t for read/write */
-  histdata_t data;
-} HIST_ENTRY;
-
-/* Size of the history-library-managed space in history entry HS. */
-#define HISTENT_BYTES(hs)	(strlen(hs.line) + strlen(hs.timestamp))
-
-/* A structure used to pass the current state of the history stuff around. */
-typedef struct _hist_state {
-  HIST_ENTRY **entries;		/* Pointer to the entries themselves. */
-  int offset;			/* The location pointer within this array. */
-  int length;			/* Number of elements within this array. */
-  int size;			/* Number of slots allocated to this array. */
-  int flags;
-} HISTORY_STATE;
-
-/* Flag values for the `flags' member of HISTORY_STATE. */
-#define HS_STIFLED	0x01
-
-/* Initialization and state management. */
-
-/* Begin a session in which the history functions might be used.  This
-   just initializes the interactive variables. */
-extern void using_history PARAMS((void));
-
-/* Return the current HISTORY_STATE of the history. */
-extern HISTORY_STATE *history_get_history_state PARAMS((void));
-
-/* Set the state of the current history array to STATE. */
-extern void history_set_history_state PARAMS((HISTORY_STATE *));
-
-/* Manage the history list. */
-
-/* Place STRING at the end of the history list.
-   The associated data field (if any) is set to NULL. */
-extern void add_history PARAMS((const char *));
-
-/* Change the timestamp associated with the most recent history entry to
-   STRING. */
-extern void add_history_time PARAMS((const char *));
-
-/* A reasonably useless function, only here for completeness.  WHICH
-   is the magic number that tells us which element to delete.  The
-   elements are numbered from 0. */
-extern HIST_ENTRY *remove_history PARAMS((int));
-
-/* Free the history entry H and return any application-specific data
-   associated with it. */
-extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
-
-/* Make the history entry at WHICH have LINE and DATA.  This returns
-   the old entry so you can dispose of the data.  In the case of an
-   invalid WHICH, a NULL pointer is returned. */
-extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
-
-/* Clear the history list and start over. */
-extern void clear_history PARAMS((void));
-
-/* Stifle the history list, remembering only MAX number of entries. */
-extern void stifle_history PARAMS((int));
-
-/* Stop stifling the history.  This returns the previous amount the
-   history was stifled by.  The value is positive if the history was
-   stifled, negative if it wasn't. */
-extern int unstifle_history PARAMS((void));
-
-/* Return 1 if the history is stifled, 0 if it is not. */
-extern int history_is_stifled PARAMS((void));
-
-/* Information about the history list. */
-
-/* Return a NULL terminated array of HIST_ENTRY which is the current input
-   history.  Element 0 of this list is the beginning of time.  If there
-   is no history, return NULL. */
-extern HIST_ENTRY **history_list PARAMS((void));
-
-/* Returns the number which says what history element we are now
-   looking at.  */
-extern int where_history PARAMS((void));
-  
-/* Return the history entry at the current position, as determined by
-   history_offset.  If there is no entry there, return a NULL pointer. */
-extern HIST_ENTRY *current_history PARAMS((void));
-
-/* Return the history entry which is logically at OFFSET in the history
-   array.  OFFSET is relative to history_base. */
-extern HIST_ENTRY *history_get PARAMS((int));
-
-/* Return the timestamp associated with the HIST_ENTRY * passed as an
-   argument */
-extern time_t history_get_time PARAMS((HIST_ENTRY *));
-
-/* Return the number of bytes that the primary history entries are using.
-   This just adds up the lengths of the_history->lines. */
-extern int history_total_bytes PARAMS((void));
-
-/* Moving around the history list. */
-
-/* Set the position in the history list to POS. */
-extern int history_set_pos PARAMS((int));
-
-/* Back up history_offset to the previous history entry, and return
-   a pointer to that entry.  If there is no previous entry, return
-   a NULL pointer. */
-extern HIST_ENTRY *previous_history PARAMS((void));
-
-/* Move history_offset forward to the next item in the input_history,
-   and return the a pointer to that entry.  If there is no next entry,
-   return a NULL pointer. */
-extern HIST_ENTRY *next_history PARAMS((void));
-
-/* Searching the history list. */
-
-/* Search the history for STRING, starting at history_offset.
-   If DIRECTION < 0, then the search is through previous entries,
-   else through subsequent.  If the string is found, then
-   current_history () is the history entry, and the value of this function
-   is the offset in the line of that history entry that the string was
-   found in.  Otherwise, nothing is changed, and a -1 is returned. */
-extern int history_search PARAMS((const char *, int));
-
-/* Search the history for STRING, starting at history_offset.
-   The search is anchored: matching lines must begin with string.
-   DIRECTION is as in history_search(). */
-extern int history_search_prefix PARAMS((const char *, int));
-
-/* Search for STRING in the history list, starting at POS, an
-   absolute index into the list.  DIR, if negative, says to search
-   backwards from POS, else forwards.
-   Returns the absolute index of the history element where STRING
-   was found, or -1 otherwise. */
-extern int history_search_pos PARAMS((const char *, int, int));
-
-/* Managing the history file. */
-
-/* Add the contents of FILENAME to the history list, a line at a time.
-   If FILENAME is NULL, then read from ~/.history.  Returns 0 if
-   successful, or errno if not. */
-extern int read_history PARAMS((const char *));
-
-/* Read a range of lines from FILENAME, adding them to the history list.
-   Start reading at the FROM'th line and end at the TO'th.  If FROM
-   is zero, start at the beginning.  If TO is less than FROM, read
-   until the end of the file.  If FILENAME is NULL, then read from
-   ~/.history.  Returns 0 if successful, or errno if not. */
-extern int read_history_range PARAMS((const char *, int, int));
-
-/* Write the current history to FILENAME.  If FILENAME is NULL,
-   then write the history list to ~/.history.  Values returned
-   are as in read_history ().  */
-extern int write_history PARAMS((const char *));
-
-/* Append NELEMENT entries to FILENAME.  The entries appended are from
-   the end of the list minus NELEMENTs up to the end of the list. */
-extern int append_history PARAMS((int, const char *));
-
-/* Truncate the history file, leaving only the last NLINES lines. */
-extern int history_truncate_file PARAMS((const char *, int));
-
-/* History expansion. */
-
-/* Expand the string STRING, placing the result into OUTPUT, a pointer
-   to a string.  Returns:
-
-   0) If no expansions took place (or, if the only change in
-      the text was the de-slashifying of the history expansion
-      character)
-   1) If expansions did take place
-  -1) If there was an error in expansion.
-   2) If the returned line should just be printed.
-
-  If an error occurred in expansion, then OUTPUT contains a descriptive
-  error message. */
-extern int history_expand PARAMS((char *, char **));
-
-/* Extract a string segment consisting of the FIRST through LAST
-   arguments present in STRING.  Arguments are broken up as in
-   the shell. */
-extern char *history_arg_extract PARAMS((int, int, const char *));
-
-/* Return the text of the history event beginning at the current
-   offset into STRING.  Pass STRING with *INDEX equal to the
-   history_expansion_char that begins this specification.
-   DELIMITING_QUOTE is a character that is allowed to end the string
-   specification for what to search for in addition to the normal
-   characters `:', ` ', `\t', `\n', and sometimes `?'. */
-extern char *get_history_event PARAMS((const char *, int *, int));
-
-/* Return an array of tokens, much as the shell might.  The tokens are
-   parsed out of STRING. */
-extern char **history_tokenize PARAMS((const char *));
-
-#if false
-/* Exported history variables. */
-extern int history_base;
-extern int history_length;
-extern int history_max_entries;
-extern char history_expansion_char;
-extern char history_subst_char;
-extern char *history_word_delimiters;
-extern char history_comment_char;
-extern char *history_no_expand_chars;
-extern char *history_search_delimiter_chars;
-extern int history_quotes_inhibit_expansion;
-
-extern int history_write_timestamps;
-
-#endif
-
diff --git a/lib/wrappers/readline/tweaked/readline.h b/lib/wrappers/readline/tweaked/readline.h
deleted file mode 100644
index b13fbdbbe..000000000
--- a/lib/wrappers/readline/tweaked/readline.h
+++ /dev/null
@@ -1,956 +0,0 @@
-/* Readline.h -- the names of functions callable from within readline. */
-
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
-
-   This file is part of the GNU Readline Library (Readline), a library
-   for reading lines of text with interactive input and history editing.      
-
-   Readline is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   Readline is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef C2NIM
-#  private readlineDll
-#  dynlib readlineDll
-#  cdecl
-#  if defined(windows)
-#    define readlineDll "readline.dll"
-#  elif defined(macosx)
-#    define readlineDll "libreadline.dynlib"
-#  else
-#    define readlineDll "libreadline.so.6(|.0)"
-#  endif
-#  prefix rl_
-#  prefix RL_
-#  suffix _t
-#  typeprefixes
-#  def PARAMS(x) x
-#  mangle end theEnd
-#  mangle type typ
-#  mangle macro theMacro
-/*#  mangle "'command_func'" TCommandFunc
-#  mangle vcpfunc TvcpFunc*/
-#endif
-
-#  include "rltypedefs.h"
-
-
-/* Some character stuff. */
-#define control_character_threshold 0x020   /* Smaller than this is control. */
-#define control_character_mask 0x1f	    /* 0x20 - 1 */
-#define meta_character_threshold 0x07f	    /* Larger than this is Meta. */
-#define control_character_bit 0x40	    /* 0x000000, must be off. */
-#define meta_character_bit 0x080	    /* x0000000, must be on. */
-#define largest_char 255		    /* Largest character value. */
-
-#define CTRL_CHAR(c) (c < control_character_threshold && ((c & 0x80) == 0))
-#define META_CHAR(c) (c > meta_character_threshold && c <= largest_char)
-
-#define CTRL(c) (c & control_character_mask)
-#define META(c) (c | meta_character_bit)
-
-#define UNMETA(c) (c & ~meta_character_bit)
-#define UNCTRL(c) (c|32|control_character_bit)
-
-/* Beware:  these only work with single-byte ASCII characters. */
-
-#define RETURN_CHAR CTRL('M'.ord)
-#define RUBOUT_CHAR 0x7f
-#define ABORT_CHAR CTRL('G'.ord)
-#define PAGE_CHAR CTRL('L'.ord)
-#define ESC_CHAR CTRL('['.ord)
-
-/* A keymap contains one entry for each key in the ASCII set.
-   Each entry consists of a type and a pointer.
-   FUNCTION is the address of a function to run, or the
-   address of a keymap to indirect through.
-   TYPE says which kind of thing FUNCTION is. */
-typedef struct _keymap_entry {
-  char type;
-  rl_command_func_t *function;
-} KEYMAP_ENTRY;
-
-/* This must be large enough to hold bindings for all of the characters
-   in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
-   and so on) plus one for subsequence matching. */
-#define KEYMAP_SIZE 257
-#define ANYOTHERKEY KEYMAP_SIZE-1
-
-/* I wanted to make the above structure contain a union of:
-   union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
-   but this made it impossible for me to create a static array.
-   Maybe I need C lessons. */
-
-typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
-typedef KEYMAP_ENTRY *Keymap;
-
-/* The values that TYPE can have in a keymap entry. */
-#define ISFUNC 0
-#define ISKMAP 1
-#define ISMACR 2
-
-#if false
-extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
-extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
-#endif
-
-/* Return a new, empty keymap.
-   Free it with free() when you are done. */
-extern Keymap rl_make_bare_keymap PARAMS((void));
-
-/* Return a new keymap which is a copy of MAP. */
-extern Keymap rl_copy_keymap PARAMS((Keymap));
-
-/* Return a new keymap with the printing characters bound to rl_insert,
-   the lowercase Meta characters bound to run their equivalents, and
-   the Meta digits bound to produce numeric arguments. */
-extern Keymap rl_make_keymap PARAMS((void));
-
-/* Free the storage associated with a keymap. */
-extern void rl_discard_keymap PARAMS((Keymap));
-
-/* These functions actually appear in bind.c */
-
-/* Return the keymap corresponding to a given name.  Names look like
-   `emacs' or `emacs-meta' or `vi-insert'.  */
-extern Keymap rl_get_keymap_by_name PARAMS((const char *));
-
-/* Return the current keymap. */
-extern Keymap rl_get_keymap PARAMS((void));
-
-/* Set the current keymap to MAP. */
-extern void rl_set_keymap PARAMS((Keymap));
-
-#  include "tilde.h"
-
-/* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION	0x0600		/* Readline 6.0 */
-#define RL_VERSION_MAJOR	6
-#define RL_VERSION_MINOR	0
-
-/* Readline data structures. */
-
-/* Maintaining the state of undo.  We remember individual deletes and inserts
-   on a chain of things to do. */
-
-/* The actions that undo knows how to undo.  Notice that UNDO_DELETE means
-   to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
-   the code tells undo what to undo, not how to undo it. */
-enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
-
-/* What an element of THE_UNDO_LIST looks like. */
-typedef struct undo_list {
-  struct undo_list *next;
-  int start, end;		/* Where the change took place. */
-  char *text;			/* The text to insert, if undoing a delete. */
-  enum undo_code what;		/* Delete, Insert, Begin, End. */
-} UNDO_LIST;
-
-/* The current undo list for RL_LINE_BUFFER. */
-extern UNDO_LIST *rl_undo_list;
-
-/* The data structure for mapping textual names to code addresses. */
-typedef struct _funmap {
-  const char *name;
-  rl_command_func_t *function;
-} FUNMAP;
-
-extern FUNMAP **funmap;
-
-/* **************************************************************** */
-/*								    */
-/*	     Functions available to bind to key sequences	    */
-/*								    */
-/* **************************************************************** */
-
-/* Bindable commands for numeric arguments. */
-extern int rl_digit_argument PARAMS((int, int));
-extern int rl_universal_argument PARAMS((int, int));
-
-/* Bindable commands for moving the cursor. */
-extern int rl_forward_byte PARAMS((int, int));
-extern int rl_forward_char PARAMS((int, int));
-extern int rl_forward PARAMS((int, int));
-extern int rl_backward_byte PARAMS((int, int));
-extern int rl_backward_char PARAMS((int, int));
-extern int rl_backward PARAMS((int, int));
-extern int rl_beg_of_line PARAMS((int, int));
-extern int rl_end_of_line PARAMS((int, int));
-extern int rl_forward_word PARAMS((int, int));
-extern int rl_backward_word PARAMS((int, int));
-extern int rl_refresh_line PARAMS((int, int));
-extern int rl_clear_screen PARAMS((int, int));
-extern int rl_skip_csi_sequence PARAMS((int, int));
-extern int rl_arrow_keys PARAMS((int, int));
-
-/* Bindable commands for inserting and deleting text. */
-extern int rl_insert PARAMS((int, int));
-extern int rl_quoted_insert PARAMS((int, int));
-extern int rl_tab_insert PARAMS((int, int));
-extern int rl_newline PARAMS((int, int));
-extern int rl_do_lowercase_version PARAMS((int, int));
-extern int rl_rubout PARAMS((int, int));
-extern int rl_delete PARAMS((int, int));
-extern int rl_rubout_or_delete PARAMS((int, int));
-extern int rl_delete_horizontal_space PARAMS((int, int));
-extern int rl_delete_or_show_completions PARAMS((int, int));
-extern int rl_insert_comment PARAMS((int, int));
-
-/* Bindable commands for changing case. */
-extern int rl_upcase_word PARAMS((int, int));
-extern int rl_downcase_word PARAMS((int, int));
-extern int rl_capitalize_word PARAMS((int, int));
-
-/* Bindable commands for transposing characters and words. */
-extern int rl_transpose_words PARAMS((int, int));
-extern int rl_transpose_chars PARAMS((int, int));
-
-/* Bindable commands for searching within a line. */
-extern int rl_char_search PARAMS((int, int));
-extern int rl_backward_char_search PARAMS((int, int));
-
-/* Bindable commands for readline's interface to the command history. */
-extern int rl_beginning_of_history PARAMS((int, int));
-extern int rl_end_of_history PARAMS((int, int));
-extern int rl_get_next_history PARAMS((int, int));
-extern int rl_get_previous_history PARAMS((int, int));
-
-/* Bindable commands for managing the mark and region. */
-extern int rl_set_mark PARAMS((int, int));
-extern int rl_exchange_point_and_mark PARAMS((int, int));
-
-/* Bindable commands to set the editing mode (emacs or vi). */
-extern int rl_vi_editing_mode PARAMS((int, int));
-extern int rl_emacs_editing_mode PARAMS((int, int));
-
-/* Bindable commands to change the insert mode (insert or overwrite) */
-extern int rl_overwrite_mode PARAMS((int, int));
-
-/* Bindable commands for managing key bindings. */
-extern int rl_re_read_init_file PARAMS((int, int));
-extern int rl_dump_functions PARAMS((int, int));
-extern int rl_dump_macros PARAMS((int, int));
-extern int rl_dump_variables PARAMS((int, int));
-
-/* Bindable commands for word completion. */
-extern int rl_complete PARAMS((int, int));
-extern int rl_possible_completions PARAMS((int, int));
-extern int rl_insert_completions PARAMS((int, int));
-extern int rl_old_menu_complete PARAMS((int, int));
-extern int rl_menu_complete PARAMS((int, int));
-extern int rl_backward_menu_complete PARAMS((int, int));
-
-/* Bindable commands for killing and yanking text, and managing the kill ring. */
-extern int rl_kill_word PARAMS((int, int));
-extern int rl_backward_kill_word PARAMS((int, int));
-extern int rl_kill_line PARAMS((int, int));
-extern int rl_backward_kill_line PARAMS((int, int));
-extern int rl_kill_full_line PARAMS((int, int));
-extern int rl_unix_word_rubout PARAMS((int, int));
-extern int rl_unix_filename_rubout PARAMS((int, int));
-extern int rl_unix_line_discard PARAMS((int, int));
-extern int rl_copy_region_to_kill PARAMS((int, int));
-extern int rl_kill_region PARAMS((int, int));
-extern int rl_copy_forward_word PARAMS((int, int));
-extern int rl_copy_backward_word PARAMS((int, int));
-extern int rl_yank PARAMS((int, int));
-extern int rl_yank_pop PARAMS((int, int));
-extern int rl_yank_nth_arg PARAMS((int, int));
-extern int rl_yank_last_arg PARAMS((int, int));
-
-#ifdef Windows
-extern int rl_paste_from_clipboard PARAMS((int, int));
-#endif
-
-/* Bindable commands for incremental searching. */
-extern int rl_reverse_search_history PARAMS((int, int));
-extern int rl_forward_search_history PARAMS((int, int));
-
-/* Bindable keyboard macro commands. */
-extern int rl_start_kbd_macro PARAMS((int, int));
-extern int rl_end_kbd_macro PARAMS((int, int));
-extern int rl_call_last_kbd_macro PARAMS((int, int));
-
-/* Bindable undo commands. */
-extern int rl_revert_line PARAMS((int, int));
-extern int rl_undo_command PARAMS((int, int));
-
-/* Bindable tilde expansion commands. */
-extern int rl_tilde_expand PARAMS((int, int));
-
-/* Bindable terminal control commands. */
-extern int rl_restart_output PARAMS((int, int));
-extern int rl_stop_output PARAMS((int, int));
-
-/* Miscellaneous bindable commands. */
-extern int rl_abort PARAMS((int, int));
-extern int rl_tty_status PARAMS((int, int));
-
-/* Bindable commands for incremental and non-incremental history searching. */
-extern int rl_history_search_forward PARAMS((int, int));
-extern int rl_history_search_backward PARAMS((int, int));
-extern int rl_noninc_forward_search PARAMS((int, int));
-extern int rl_noninc_reverse_search PARAMS((int, int));
-extern int rl_noninc_forward_search_again PARAMS((int, int));
-extern int rl_noninc_reverse_search_again PARAMS((int, int));
-
-/* Bindable command used when inserting a matching close character. */
-extern int rl_insert_close PARAMS((int, int));
-
-/* Not available unless READLINE_CALLBACKS is defined. */
-extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
-extern void rl_callback_read_char PARAMS((void));
-extern void rl_callback_handler_remove PARAMS((void));
-
-/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
-/* VI-mode bindable commands. */
-extern int rl_vi_redo PARAMS((int, int));
-extern int rl_vi_undo PARAMS((int, int));
-extern int rl_vi_yank_arg PARAMS((int, int));
-extern int rl_vi_fetch_history PARAMS((int, int));
-extern int rl_vi_search_again PARAMS((int, int));
-extern int rl_vi_search PARAMS((int, int));
-extern int rl_vi_complete PARAMS((int, int));
-extern int rl_vi_tilde_expand PARAMS((int, int));
-extern int rl_vi_prev_word PARAMS((int, int));
-extern int rl_vi_next_word PARAMS((int, int));
-extern int rl_vi_end_word PARAMS((int, int));
-extern int rl_vi_insert_beg PARAMS((int, int));
-extern int rl_vi_append_mode PARAMS((int, int));
-extern int rl_vi_append_eol PARAMS((int, int));
-extern int rl_vi_eof_maybe PARAMS((int, int));
-extern int rl_vi_insertion_mode PARAMS((int, int));
-extern int rl_vi_insert_mode PARAMS((int, int));
-extern int rl_vi_movement_mode PARAMS((int, int));
-extern int rl_vi_arg_digit PARAMS((int, int));
-extern int rl_vi_change_case PARAMS((int, int));
-extern int rl_vi_put PARAMS((int, int));
-extern int rl_vi_column PARAMS((int, int));
-extern int rl_vi_delete_to PARAMS((int, int));
-extern int rl_vi_change_to PARAMS((int, int));
-extern int rl_vi_yank_to PARAMS((int, int));
-extern int rl_vi_rubout PARAMS((int, int));
-extern int rl_vi_delete PARAMS((int, int));
-extern int rl_vi_back_to_indent PARAMS((int, int));
-extern int rl_vi_first_print PARAMS((int, int));
-extern int rl_vi_char_search PARAMS((int, int));
-extern int rl_vi_match PARAMS((int, int));
-extern int rl_vi_change_char PARAMS((int, int));
-extern int rl_vi_subst PARAMS((int, int));
-extern int rl_vi_overstrike PARAMS((int, int));
-extern int rl_vi_overstrike_delete PARAMS((int, int));
-extern int rl_vi_replace PARAMS((int, int));
-extern int rl_vi_set_mark PARAMS((int, int));
-extern int rl_vi_goto_mark PARAMS((int, int));
-
-/* VI-mode utility functions. */
-extern int rl_vi_check PARAMS((void));
-extern int rl_vi_domove PARAMS((int, int *));
-extern int rl_vi_bracktype PARAMS((int));
-
-extern void rl_vi_start_inserting PARAMS((int, int, int));
-
-/* VI-mode pseudo-bindable commands, used as utility functions. */
-extern int rl_vi_fWord PARAMS((int, int));
-extern int rl_vi_bWord PARAMS((int, int));
-extern int rl_vi_eWord PARAMS((int, int));
-extern int rl_vi_fword PARAMS((int, int));
-extern int rl_vi_bword PARAMS((int, int));
-extern int rl_vi_eword PARAMS((int, int));
-
-/* **************************************************************** */
-/*								    */
-/*			Well Published Functions		    */
-/*								    */
-/* **************************************************************** */
-
-/* Readline functions. */
-/* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
-extern char *readline PARAMS((const char *));
-
-extern int rl_set_prompt PARAMS((const char *));
-extern int rl_expand_prompt PARAMS((char *));
-
-extern int rl_initialize PARAMS((void));
-
-/* Undocumented; unused by readline */
-extern int rl_discard_argument PARAMS((void));
-
-/* Utility functions to bind keys to readline commands. */
-extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
-extern int rl_bind_key PARAMS((int, rl_command_func_t *));
-extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
-extern int rl_unbind_key PARAMS((int));
-extern int rl_unbind_key_in_map PARAMS((int, Keymap));
-extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
-extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
-extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
-extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
-extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
-extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
-extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
-extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
-extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
-
-extern char *rl_variable_value PARAMS((const char *));
-extern int rl_variable_bind PARAMS((const char *, const char *));
-
-/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
-extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
-
-/* Backwards compatibility, use rl_generic_bind instead. */
-extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
-
-/* Undocumented in the texinfo manual; not really useful to programs. */
-extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
-extern char *rl_untranslate_keyseq PARAMS((int));
-
-extern rl_command_func_t *rl_named_function PARAMS((const char *));
-extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
-
-extern void rl_list_funmap_names PARAMS((void));
-extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
-extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
- 
-extern void rl_function_dumper PARAMS((int));
-extern void rl_macro_dumper PARAMS((int));
-extern void rl_variable_dumper PARAMS((int));
-
-extern int rl_read_init_file PARAMS((const char *));
-extern int rl_parse_and_bind PARAMS((char *));
-
-/* Functions for manipulating keymaps. */
-extern Keymap rl_make_bare_keymap PARAMS((void));
-extern Keymap rl_copy_keymap PARAMS((Keymap));
-extern Keymap rl_make_keymap PARAMS((void));
-extern void rl_discard_keymap PARAMS((Keymap));
-
-extern Keymap rl_get_keymap_by_name PARAMS((const char *));
-extern char *rl_get_keymap_name PARAMS((Keymap));
-extern void rl_set_keymap PARAMS((Keymap));
-extern Keymap rl_get_keymap PARAMS((void));
-/* Undocumented; used internally only. */
-extern void rl_set_keymap_from_edit_mode PARAMS((void));
-extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
-
-/* Functions for manipulating the funmap, which maps command names to functions. */
-extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
-extern const char **rl_funmap_names PARAMS((void));
-/* Undocumented, only used internally -- there is only one funmap, and this
-   function may be called only once. */
-extern void rl_initialize_funmap PARAMS((void));
-
-/* Utility functions for managing keyboard macros. */
-extern void rl_push_macro_input PARAMS((char *));
-
-/* Functions for undoing, from undo.c */
-extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
-extern void rl_free_undo_list PARAMS((void));
-extern int rl_do_undo PARAMS((void));
-extern int rl_begin_undo_group PARAMS((void));
-extern int rl_end_undo_group PARAMS((void));
-extern int rl_modifying PARAMS((int, int));
-
-/* Functions for redisplay. */
-extern void rl_redisplay PARAMS((void));
-extern int rl_on_new_line PARAMS((void));
-extern int rl_on_new_line_with_prompt PARAMS((void));
-extern int rl_forced_update_display PARAMS((void));
-extern int rl_clear_message PARAMS((void));
-extern int rl_reset_line_state PARAMS((void));
-extern int rl_crlf PARAMS((void));
-
-extern int rl_message (const char *, ...);
-
-extern int rl_show_char PARAMS((int));
-
-/* Undocumented in texinfo manual. */
-extern int rl_character_len PARAMS((int, int));
-
-/* Save and restore internal prompt redisplay information. */
-extern void rl_save_prompt PARAMS((void));
-extern void rl_restore_prompt PARAMS((void));
-
-/* Modifying text. */
-extern void rl_replace_line PARAMS((const char *, int));
-extern int rl_insert_text PARAMS((const char *));
-extern int rl_delete_text PARAMS((int, int));
-extern int rl_kill_text PARAMS((int, int));
-extern char *rl_copy_text PARAMS((int, int));
-
-/* Terminal and tty mode management. */
-extern void rl_prep_terminal PARAMS((int));
-extern void rl_deprep_terminal PARAMS((void));
-extern void rl_tty_set_default_bindings PARAMS((Keymap));
-extern void rl_tty_unset_default_bindings PARAMS((Keymap));
-
-extern int rl_reset_terminal PARAMS((const char *));
-extern void rl_resize_terminal PARAMS((void));
-extern void rl_set_screen_size PARAMS((int, int));
-extern void rl_get_screen_size PARAMS((int *, int *));
-extern void rl_reset_screen_size PARAMS((void));
-
-extern char *rl_get_termcap PARAMS((const char *));
-
-/* Functions for character input. */
-extern int rl_stuff_char PARAMS((int));
-extern int rl_execute_next PARAMS((int));
-extern int rl_clear_pending_input PARAMS((void));
-extern int rl_read_key PARAMS((void));
-extern int rl_getc PARAMS((TFile));
-extern int rl_set_keyboard_input_timeout PARAMS((int));
-
-/* `Public' utility functions . */
-extern void rl_extend_line_buffer PARAMS((int));
-extern int rl_ding PARAMS((void));
-extern int rl_alphabetic PARAMS((int));
-extern void rl_free PARAMS((void *));
-
-/* Readline signal handling, from signals.c */
-extern int rl_set_signals PARAMS((void));
-extern int rl_clear_signals PARAMS((void));
-extern void rl_cleanup_after_signal PARAMS((void));
-extern void rl_reset_after_signal PARAMS((void));
-extern void rl_free_line_state PARAMS((void));
-
-extern void rl_echo_signal_char PARAMS((int)); 
-
-extern int rl_set_paren_blink_timeout PARAMS((int));
-
-/* Undocumented. */
-extern int rl_maybe_save_line PARAMS((void));
-extern int rl_maybe_unsave_line PARAMS((void));
-extern int rl_maybe_replace_line PARAMS((void));
-
-/* Completion functions. */
-extern int rl_complete_internal PARAMS((int));
-extern void rl_display_match_list PARAMS((char **, int, int));
-
-extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
-extern char *rl_username_completion_function PARAMS((const char *, int));
-extern char *rl_filename_completion_function PARAMS((const char *, int));
-
-extern int rl_completion_mode PARAMS((rl_command_func_t *));
-
-/* **************************************************************** */
-/*								    */
-/*			Well Published Variables		    */
-/*								    */
-/* **************************************************************** */
-
-#if false
-
-/* The version of this incarnation of the readline library. */
-extern const char *rl_library_version;		/* e.g., "4.2" */
-extern int rl_readline_version;			/* e.g., 0x0402 */
-
-/* True if this is real GNU readline. */
-extern int rl_gnu_readline_p;
-
-/* Flags word encapsulating the current readline state. */
-extern int rl_readline_state;
-
-/* Says which editing mode readline is currently using.  1 means emacs mode;
-   0 means vi mode. */
-extern int rl_editing_mode;
-
-/* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
-   overwrite mode.  Reset to insert mode on each input line. */
-extern int rl_insert_mode;
-
-/* The name of the calling program.  You should initialize this to
-   whatever was in argv[0].  It is used when parsing conditionals. */
-extern const char *rl_readline_name;
-
-/* The prompt readline uses.  This is set from the argument to
-   readline (), and should not be assigned to directly. */
-extern char *rl_prompt;
-
-/* The prompt string that is actually displayed by rl_redisplay.  Public so
-   applications can more easily supply their own redisplay functions. */
-extern char *rl_display_prompt;
-
-/* The line buffer that is in use. */
-extern char *rl_line_buffer;
-
-/* The location of point, and end. */
-extern int rl_point;
-extern int rl_end;
-
-/* The mark, or saved cursor position. */
-extern int rl_mark;
-
-/* Flag to indicate that readline has finished with the current input
-   line and should return it. */
-extern int rl_done;
-
-/* If set to a character value, that will be the next keystroke read. */
-extern int rl_pending_input;
-
-/* Non-zero if we called this function from _rl_dispatch().  It's present
-   so functions can find out whether they were called from a key binding
-   or directly from an application. */
-extern int rl_dispatching;
-
-/* Non-zero if the user typed a numeric argument before executing the
-   current function. */
-extern int rl_explicit_arg;
-
-/* The current value of the numeric argument specified by the user. */
-extern int rl_numeric_arg;
-
-/* The address of the last command function Readline executed. */
-extern rl_command_func_t *rl_last_func;
-
-/* The name of the terminal to use. */
-extern const char *rl_terminal_name;
-
-/* The input and output streams. */
-extern FILE *rl_instream;
-extern FILE *rl_outstream;
-
-/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
-   greater precedence than values fetched from the kernel when computing the
-   screen dimensions. */
-extern int rl_prefer_env_winsize;
-
-/* If non-zero, then this is the address of a function to call just
-   before readline_internal () prints the first prompt. */
-extern rl_hook_func_t *rl_startup_hook;
-
-/* If non-zero, this is the address of a function to call just before
-   readline_internal_setup () returns and readline_internal starts
-   reading input characters. */
-extern rl_hook_func_t *rl_pre_input_hook;
-      
-/* The address of a function to call periodically while Readline is
-   awaiting character input, or NULL, for no event handling. */
-extern rl_hook_func_t *rl_event_hook;
-
-/* The address of the function to call to fetch a character from the current
-   Readline input stream */
-extern rl_getc_func_t *rl_getc_function;
-
-extern rl_voidfunc_t *rl_redisplay_function;
-
-extern rl_vintfunc_t *rl_prep_term_function;
-extern rl_voidfunc_t *rl_deprep_term_function;
-
-/* Dispatch variables. */
-extern Keymap rl_executing_keymap;
-extern Keymap rl_binding_keymap;
-
-/* Display variables. */
-/* If non-zero, readline will erase the entire line, including any prompt,
-   if the only thing typed on an otherwise-blank line is something bound to
-   rl_newline. */
-extern int rl_erase_empty_line;
-
-/* If non-zero, the application has already printed the prompt (rl_prompt)
-   before calling readline, so readline should not output it the first time
-   redisplay is done. */
-extern int rl_already_prompted;
-
-/* A non-zero value means to read only this many characters rather than
-   up to a character bound to accept-line. */
-extern int rl_num_chars_to_read;
-
-/* The text of a currently-executing keyboard macro. */
-extern char *rl_executing_macro;
-
-/* Variables to control readline signal handling. */
-/* If non-zero, readline will install its own signal handlers for
-   SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
-extern int rl_catch_signals;
-
-/* If non-zero, readline will install a signal handler for SIGWINCH
-   that also attempts to call any calling application's SIGWINCH signal
-   handler.  Note that the terminal is not cleaned up before the
-   application's signal handler is called; use rl_cleanup_after_signal()
-   to do that. */
-extern int rl_catch_sigwinch;
-
-/* Completion variables. */
-/* Pointer to the generator function for completion_matches ().
-   NULL means to use rl_filename_completion_function (), the default
-   filename completer. */
-extern rl_compentry_func_t *rl_completion_entry_function;
-
-/* Optional generator for menu completion.  Default is
-   rl_completion_entry_function (rl_filename_completion_function). */
- extern rl_compentry_func_t *rl_menu_completion_entry_function;
-
-/* If rl_ignore_some_completions_function is non-NULL it is the address
-   of a function to call after all of the possible matches have been
-   generated, but before the actual completion is done to the input line.
-   The function is called with one argument; a NULL terminated array
-   of (char *).  If your function removes any of the elements, they
-   must be free()'ed. */
-extern rl_compignore_func_t *rl_ignore_some_completions_function;
-
-/* Pointer to alternative function to create matches.
-   Function is called with TEXT, START, and END.
-   START and END are indices in RL_LINE_BUFFER saying what the boundaries
-   of TEXT are.
-   If this function exists and returns NULL then call the value of
-   rl_completion_entry_function to try to match, otherwise use the
-   array of strings returned. */
-extern rl_completion_func_t *rl_attempted_completion_function;
-
-/* The basic list of characters that signal a break between words for the
-   completer routine.  The initial contents of this variable is what
-   breaks words in the shell, i.e. "n\"\\'`@$>". */
-extern const char *rl_basic_word_break_characters;
-
-/* The list of characters that signal a break between words for
-   rl_complete_internal.  The default list is the contents of
-   rl_basic_word_break_characters.  */
-extern /*const*/ char *rl_completer_word_break_characters;
-
-/* Hook function to allow an application to set the completion word
-   break characters before readline breaks up the line.  Allows
-   position-dependent word break characters. */
-extern rl_cpvfunc_t *rl_completion_word_break_hook;
-
-/* List of characters which can be used to quote a substring of the line.
-   Completion occurs on the entire substring, and within the substring   
-   rl_completer_word_break_characters are treated as any other character,
-   unless they also appear within this list. */
-extern const char *rl_completer_quote_characters;
-
-/* List of quote characters which cause a word break. */
-extern const char *rl_basic_quote_characters;
-
-/* List of characters that need to be quoted in filenames by the completer. */
-extern const char *rl_filename_quote_characters;
-
-/* List of characters that are word break characters, but should be left
-   in TEXT when it is passed to the completion function.  The shell uses
-   this to help determine what kind of completing to do. */
-extern const char *rl_special_prefixes;
-
-/* If non-zero, then this is the address of a function to call when
-   completing on a directory name.  The function is called with
-   the address of a string (the current directory name) as an arg.  It
-   changes what is displayed when the possible completions are printed
-   or inserted. */
-extern rl_icppfunc_t *rl_directory_completion_hook;
-
-/* If non-zero, this is the address of a function to call when completing
-   a directory name.  This function takes the address of the directory name
-   to be modified as an argument.  Unlike rl_directory_completion_hook, it
-   only modifies the directory name used in opendir(2), not what is displayed
-   when the possible completions are printed or inserted.  It is called
-   before rl_directory_completion_hook.  I'm not happy with how this works
-   yet, so it's undocumented. */
-extern rl_icppfunc_t *rl_directory_rewrite_hook;
-
-/* If non-zero, this is the address of a function to call when reading
-   directory entries from the filesystem for completion and comparing
-   them to the partial word to be completed.  The function should
-   either return its first argument (if no conversion takes place) or
-   newly-allocated memory.  This can, for instance, convert filenames
-   between character sets for comparison against what's typed at the
-   keyboard.  The returned value is what is added to the list of
-   matches.  The second argument is the length of the filename to be
-   converted. */
-extern rl_dequote_func_t *rl_filename_rewrite_hook;
-
-/* If non-zero, then this is the address of a function to call when
-   completing a word would normally display the list of possible matches.
-   This function is called instead of actually doing the display.
-   It takes three arguments: (char **matches, int num_matches, int max_length)
-   where MATCHES is the array of strings that matched, NUM_MATCHES is the
-   number of strings in that array, and MAX_LENGTH is the length of the
-   longest string in that array. */
-extern rl_compdisp_func_t *rl_completion_display_matches_hook;
-
-/* Non-zero means that the results of the matches are to be treated
-   as filenames.  This is ALWAYS zero on entry, and can only be changed
-   within a completion entry finder function. */
-extern int rl_filename_completion_desired;
-
-/* Non-zero means that the results of the matches are to be quoted using
-   double quotes (or an application-specific quoting mechanism) if the
-   filename contains any characters in rl_word_break_chars.  This is
-   ALWAYS non-zero on entry, and can only be changed within a completion
-   entry finder function. */
-extern int rl_filename_quoting_desired;
-
-/* Set to a function to quote a filename in an application-specific fashion.
-   Called with the text to quote, the type of match found (single or multiple)
-   and a pointer to the quoting character to be used, which the function can
-   reset if desired. */
-extern rl_quote_func_t *rl_filename_quoting_function;
-
-/* Function to call to remove quoting characters from a filename.  Called
-   before completion is attempted, so the embedded quotes do not interfere
-   with matching names in the file system. */
-extern rl_dequote_func_t *rl_filename_dequoting_function;
-
-/* Function to call to decide whether or not a word break character is
-   quoted.  If a character is quoted, it does not break words for the
-   completer. */
-extern rl_linebuf_func_t *rl_char_is_quoted_p;
-
-/* Non-zero means to suppress normal filename completion after the
-   user-specified completion function has been called. */
-extern int rl_attempted_completion_over;
-
-/* Set to a character describing the type of completion being attempted by
-   rl_complete_internal; available for use by application completion
-   functions. */
-extern int rl_completion_type;
-
-/* Set to the last key used to invoke one of the completion functions */
-extern int rl_completion_invoking_key;
-
-/* Up to this many items will be displayed in response to a
-   possible-completions call.  After that, we ask the user if she
-   is sure she wants to see them all.  The default value is 100. */
-extern int rl_completion_query_items;
-
-/* Character appended to completed words when at the end of the line.  The
-   default is a space.  Nothing is added if this is '\0'. */
-extern int rl_completion_append_character;
-
-/* If set to non-zero by an application completion function,
-   rl_completion_append_character will not be appended. */
-extern int rl_completion_suppress_append;
-
-/* Set to any quote character readline thinks it finds before any application
-   completion function is called. */
-extern int rl_completion_quote_character;
-
-/* Set to a non-zero value if readline found quoting anywhere in the word to
-   be completed; set before any application completion function is called. */
-extern int rl_completion_found_quote;
-
-/* If non-zero, the completion functions don't append any closing quote.
-   This is set to 0 by rl_complete_internal and may be changed by an
-   application-specific completion function. */
-extern int rl_completion_suppress_quote;
-
-/* If non-zero, readline will sort the completion matches.  On by default. */
-extern int rl_sort_completion_matches;
-
-/* If non-zero, a slash will be appended to completed filenames that are
-   symbolic links to directory names, subject to the value of the
-   mark-directories variable (which is user-settable).  This exists so
-   that application completion functions can override the user's preference
-   (set via the mark-symlinked-directories variable) if appropriate.
-   It's set to the value of _rl_complete_mark_symlink_dirs in
-   rl_complete_internal before any application-specific completion
-   function is called, so without that function doing anything, the user's
-   preferences are honored. */
-extern int rl_completion_mark_symlink_dirs;
-
-/* If non-zero, then disallow duplicates in the matches. */
-extern int rl_ignore_completion_duplicates;
-
-/* If this is non-zero, completion is (temporarily) inhibited, and the
-   completion character will be inserted as any other. */
-extern int rl_inhibit_completion;
-
-#endif
-
-/* Input error; can be returned by (*rl_getc_function) if readline is reading
-   a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
-#define READERR			(-2)
-
-/* Definitions available for use by readline clients. */
-#define RL_PROMPT_START_IGNORE	'\001'
-#define RL_PROMPT_END_IGNORE	'\002'
-
-/* Possible values for do_replace argument to rl_filename_quoting_function,
-   called by rl_complete_internal. */
-#define NO_MATCH        0
-#define SINGLE_MATCH    1
-#define MULT_MATCH      2
-
-/* Possible state values for rl_readline_state */
-#define RL_STATE_NONE		0x000000		/* no state; before first call */
-
-#define RL_STATE_INITIALIZING	0x000001	/* initializing */
-#define RL_STATE_INITIALIZED	0x000002	/* initialization done */
-#define RL_STATE_TERMPREPPED	0x000004	/* terminal is prepped */
-#define RL_STATE_READCMD	0x000008	/* reading a command key */
-#define RL_STATE_METANEXT	0x000010	/* reading input after ESC */
-#define RL_STATE_DISPATCHING	0x000020	/* dispatching to a command */
-#define RL_STATE_MOREINPUT	0x000040	/* reading more input in a command function */
-#define RL_STATE_ISEARCH	0x000080	/* doing incremental search */
-#define RL_STATE_NSEARCH	0x000100	/* doing non-inc search */
-#define RL_STATE_SEARCH		0x000200	/* doing a history search */
-#define RL_STATE_NUMERICARG	0x000400	/* reading numeric argument */
-#define RL_STATE_MACROINPUT	0x000800	/* getting input from a macro */
-#define RL_STATE_MACRODEF	0x001000	/* defining keyboard macro */
-#define RL_STATE_OVERWRITE	0x002000	/* overwrite mode */
-#define RL_STATE_COMPLETING	0x004000	/* doing completion */
-#define RL_STATE_SIGHANDLER	0x008000	/* in readline sighandler */
-#define RL_STATE_UNDOING	0x010000	/* doing an undo */
-#define RL_STATE_INPUTPENDING	0x020000	/* rl_execute_next called */
-#define RL_STATE_TTYCSAVED	0x040000	/* tty special chars saved */
-#define RL_STATE_CALLBACK	0x080000	/* using the callback interface */
-#define RL_STATE_VIMOTION	0x100000	/* reading vi motion arg */
-#define RL_STATE_MULTIKEY	0x200000	/* reading multiple-key command */
-#define RL_STATE_VICMDONCE	0x400000	/* entered vi command mode at least once */
-#define RL_STATE_REDISPLAYING	0x800000	/* updating terminal display */
-
-#define RL_STATE_DONE		0x1000000	/* done; accepted line */
-
-#define RL_SETSTATE(x)		(rl_readline_state |= (x))
-#define RL_UNSETSTATE(x)	(rl_readline_state &= ~(x))
-#define RL_ISSTATE(x)		(rl_readline_state & (x))
-
-struct readline_state {
-  /* line state */
-  int point;
-  int end;
-  int mark;
-  char *buffer;
-  int buflen;
-  UNDO_LIST *ul;
-  char *prompt;
-
-  /* global state */
-  int rlstate;
-  int done;
-  Keymap kmap;
-
-  /* input state */
-  rl_command_func_t *lastfunc;
-  int insmode;
-  int edmode;
-  int kseqlen;
-  FILE *inf;
-  FILE *outf;
-  int pendingin;
-  char *macro;
-
-  /* signal state */
-  int catchsigs;
-  int catchsigwinch;
-
-  /* search state */
-
-  /* completion state */
-
-  /* options state */
-
-  /* reserved for future expansion, so the struct size doesn't change */
-  char reserved[64];
-};
-
-extern int rl_save_state PARAMS((struct readline_state *));
-extern int rl_restore_state PARAMS((struct readline_state *));
-
diff --git a/lib/wrappers/readline/tweaked/rltypedefs.h b/lib/wrappers/readline/tweaked/rltypedefs.h
deleted file mode 100644
index 46bb42567..000000000
--- a/lib/wrappers/readline/tweaked/rltypedefs.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* rltypedefs.h -- Type declarations for readline functions. */
-
-/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
-
-   This file is part of the GNU Readline Library (Readline), a library
-   for reading lines of text with interactive input and history editing.      
-
-   Readline is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   Readline is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef C2NIM
-#  cdecl
-#  prefix rl_
-#  prefix RL_
-#  suffix _t
-#  typeprefixes
-#  def PARAMS(x) x
-#endif
-
-typedef int (*Function) ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
-
-/* Bindable functions */
-typedef int rl_command_func_t PARAMS((int, int));
-
-/* Typedefs for the completion system */
-typedef char *rl_compentry_func_t PARAMS((const char *, int));
-typedef char **rl_completion_func_t PARAMS((const char *, int, int));
-
-typedef char *rl_quote_func_t PARAMS((char *, int, char *));
-typedef char *rl_dequote_func_t PARAMS((char *, int));
-
-typedef int rl_compignore_func_t PARAMS((char **));
-
-typedef void rl_compdisp_func_t PARAMS((char **, int, int));
-
-/* Type for input and pre-read hook functions like rl_event_hook */
-typedef int rl_hook_func_t PARAMS((void));
-
-/* Input function type */
-typedef int rl_getc_func_t PARAMS((TFile));
-
-/* Generic function that takes a character buffer (which could be the readline
-   line buffer) and an index into it (which could be rl_point) and returns
-   an int. */
-typedef int rl_linebuf_func_t PARAMS((char *, int));
-
-/* `Generic' function pointer typedefs */
-typedef int rl_intfunc_t PARAMS((int));
-typedef int rl_ivoidfunc_t PARAMS((void));
-
-typedef int rl_icpfunc_t PARAMS((char *));
-typedef int rl_icppfunc_t PARAMS((char **));
-
-typedef void rl_voidfunc_t PARAMS((void));
-typedef void rl_vintfunc_t PARAMS((int));
-typedef void rl_vcpfunc_t PARAMS((char *));
-typedef void rl_vcppfunc_t PARAMS((char **));
-
-typedef char *rl_cpvfunc_t PARAMS((void));
-typedef char *rl_cpifunc_t PARAMS((int));
-typedef char *rl_cpcpfunc_t PARAMS((char  *));
-typedef char *rl_cpcppfunc_t PARAMS((char  **));
-
-
diff --git a/lib/wrappers/readline/tweaked/tilde.h b/lib/wrappers/readline/tweaked/tilde.h
deleted file mode 100644
index d91d0418d..000000000
--- a/lib/wrappers/readline/tweaked/tilde.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* tilde.h: Externally available variables and function in libtilde.a. */
-
-/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
-
-   This file contains the Readline Library (Readline), a set of
-   routines for providing Emacs style line input to programs that ask
-   for it.
-
-   Readline is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   Readline is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef C2NIM
-#  private tildeDll
-#  dynlib tildeDll
-#  cdecl
-#  if defined(windows)
-#    define tildeDll "tilde.dll"
-#  elif defined(macosx)
-#    define tildeDll "libtilde.dynlib"
-#  else
-#    define tildeDll "libtilde.so.6(|.0)"
-#  endif
-#  prefix tilde_
-#  suffix _t
-#  typeprefixes
-#  def PARAMS(x) x
-#endif
-
-typedef char *tilde_hook_func_t PARAMS((char *));
-
-#if false
-
-/* If non-null, this contains the address of a function that the application
-   wants called before trying the standard tilde expansions.  The function
-   is called with the text sans tilde, and returns a malloc()'ed string
-   which is the expansion, or a NULL pointer if the expansion fails. */
-extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
-
-/* If non-null, this contains the address of a function to call if the
-   standard meaning for expanding a tilde fails.  The function is called
-   with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
-   which is the expansion, or a NULL pointer if there is no expansion. */
-extern tilde_hook_func_t *tilde_expansion_failure_hook;
-
-/* When non-null, this is a NULL terminated array of strings which
-   are duplicates for a tilde prefix.  Bash uses this to expand
-   `=~' and `:~'. */
-extern char **tilde_additional_prefixes;
-
-/* When non-null, this is a NULL terminated array of strings which match
-   the end of a username, instead of just "/".  Bash sets this to
-   `:' and `=~'. */
-extern char **tilde_additional_suffixes;
-
-/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand PARAMS((const char *));
-
-/* Do the work of tilde expansion on FILENAME.  FILENAME starts with a
-   tilde.  If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word PARAMS((const char *));
-
-/* Find the portion of the string beginning with ~ that should be expanded. */
-extern char *tilde_find_word PARAMS((const char *, int, int *));
-
-#endif
-
diff --git a/lib/wrappers/sdl/sdl.nim b/lib/wrappers/sdl/sdl.nim
deleted file mode 100644
index 376de8e08..000000000
--- a/lib/wrappers/sdl/sdl.nim
+++ /dev/null
@@ -1,2579 +0,0 @@
-#******************************************************************************
-#
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
-#             Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997-2004  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL.h
-#                          SDL_main.h
-#                          SDL_types.h
-#                          SDL_rwops.h
-#                          SDL_timer.h
-#                          SDL_audio.h
-#                          SDL_cdrom.h
-#                          SDL_joystick.h
-#                          SDL_mouse.h
-#                          SDL_keyboard.h
-#                          SDL_events.h
-#                          SDL_video.h
-#                          SDL_byteorder.h
-#                          SDL_version.h
-#                          SDL_active.h
-#                          SDL_thread.h
-#                          SDL_mutex .h
-#                          SDL_getenv.h
-#                          SDL_loadso.h
-#
-# The initial developer of this Pascal code was :
-# Dominique Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominique Louis are
-# Copyright (C) 2000 - 2004 Dominique Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so
-#   They are available from...
-#   http://www.libsdl.org .
-#
-# Programming Notes
-# -----------------
-#
-#
-#
-#
-# Revision History
-# ----------------
-#   May      08 2001 - DL : Added Keyboard  State Array ( See demos for how to
-#                           use )
-#                           PKeyStateArr = ^TKeyStateArr;
-#                           TKeyStateArr = array[0..65000] of byte;
-#                           As most games will need it.
-#
-#   April    02 2001 - DL : Added SDL_getenv.h definitions and tested version
-#                           1.2.0 compatibility.
-#
-#   March    13 2001 - MT : Added Linux compatibility.
-#
-#   March    10 2001 - MT : Added externalsyms for DEFINES
-#                           Changed the license header
-#
-#   March    09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem
-#
-#   March    01 2001 - DL : Update conversion of version 1.1.8
-#
-#   July     22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions
-#                           from Matthias Thoma and Eric Grange.
-#
-#   October  12 2001 - DL : Various changes as suggested by Matthias Thoma and
-#                           David Acklam
-#
-#   October  24 2001 - DL : Added FreePascal support as per suggestions from
-#                           Dean Ellis.
-#
-#   October  27 2001 - DL : Added SDL_BUTTON macro
-#
-#  November  08 2001 - DL : Bug fix as pointed out by Puthoon.
-#
-#  November  29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon
-#                           Rushton.
-#
-#  November  30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton.
-#
-#  December  11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate usage in
-#                           Components
-#
-#  January   05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias
-#                           Thoma and also made sure the _getenv from
-#                           MSVCRT.DLL uses the right calling convention
-#
-#  January   25 2002 - DL : Updated conversion of SDL_AddTimer &
-#                           SDL_RemoveTimer as per suggestions from Matthias
-#                           Thoma.
-#
-#  January   27 2002 - DL : Commented out exported function putenv and getenv
-#                           So that developers get used to using SDL_putenv
-#                           SDL_getenv, as they are more portable
-#
-#  March     05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users.
-#
-#  October   23 2002 - DL : Added Delphi 3 Define of Win32.
-#                           If you intend to you Delphi 3...
-#                           ( which is officially unsupported ) make sure you
-#                           remove references to $EXTERNALSYM in this and other
-#                           SDL files.
-#
-# November  29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was
-#                          pointed out by Todd Lang
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#
-#  Revision 1.31  2007/05/29 21:30:48  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.30  2007/05/29 19:31:03  savage
-#  Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold)
-#
-#  Revision 1.29  2007/05/20 20:29:11  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.26  2007/02/11 13:38:04  savage
-#  Added Nintendo DS support - Thanks Dean.
-#
-#  Revision 1.25  2006/12/02 00:12:52  savage
-#  Updated to latest version
-#
-#  Revision 1.24  2006/05/18 21:10:04  savage
-#  Added 1.2.10 Changes
-#
-#  Revision 1.23  2005/12/04 23:17:52  drellis
-#  Added declaration of SInt8 and PSInt8
-#
-#  Revision 1.22  2005/05/24 21:59:03  savage
-#  Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis.
-#
-#  Revision 1.21  2005/05/22 18:42:31  savage
-#  Changes as suggested by Michalis Kamburelis. Thanks again.
-#
-#  Revision 1.20  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.19  2005/01/05 01:47:06  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.18  2005/01/04 23:14:41  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.17  2005/01/03 18:40:59  savage
-#  Updated Version number to reflect latest one
-#
-#  Revision 1.16  2005/01/01 02:02:06  savage
-#  Updated to v1.2.8
-#
-#  Revision 1.15  2004/12/24 18:57:11  savage
-#  forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
-#
-#  Revision 1.14  2004/12/23 23:42:18  savage
-#  Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatibility.
-#
-#  Revision 1.13  2004/09/30 22:31:59  savage
-#  Updated with slightly different header comments
-#
-#  Revision 1.12  2004/09/12 21:52:58  savage
-#  Slight changes to fix some issues with the sdl classes.
-#
-#  Revision 1.11  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.10  2004/07/20 23:57:33  savage
-#  Thanks to Paul Toth for spotting an error in the SDL Audio Conversion structures.
-#  In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
-#
-#  Revision 1.9  2004/07/03 22:07:22  savage
-#  Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
-#
-#  Revision 1.8  2004/05/10 14:10:03  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.7  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.6  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.5  2004/02/22 15:32:10  savage
-#  SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
-#
-#  Revision 1.4  2004/02/21 23:24:29  savage
-#  SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
-#
-#  Revision 1.3  2004/02/18 22:35:51  savage
-#  Brought sdl.pas up to 1.2.7 compatibility
-#  Thus...
-#  Added SDL_GL_STEREO,
-#      SDL_GL_MULTISAMPLEBUFFERS,
-#      SDL_GL_MULTISAMPLESAMPLES
-#
-#  Add DLL/Shared object functions
-#  function SDL_LoadObject( const sofile : PChar ) : pointer;
-#
-#  function SDL_LoadFunction( handle : pointer; const name : PChar ) : pointer;
-#
-#  procedure SDL_UnloadObject( handle : pointer );
-#
-#  Added function to create RWops from const memory: SDL_RWFromConstMem()
-#  function SDL_RWFromConstMem(const mem: pointer; size: Integer) : PSDL_RWops;
-#
-#  Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
-#
-#  Revision 1.2  2004/02/17 21:37:12  savage
-#  Tidying up of units
-#
-#  Revision 1.1  2004/02/05 00:08:20  savage
-#  Module 1.0 release
-#
-#
-
-{.deadCodeElim: on.}
-import unsigned
-when defined(windows): 
-  const 
-    LibName = "SDL.dll"
-elif defined(macosx): 
-  const 
-    LibName = "libSDL-1.2.0.dylib"
-else: 
-  const 
-    LibName = "libSDL.so(|.1|.0)"
-const 
-  MAJOR_VERSION* = 1
-  MINOR_VERSION* = 2
-  PATCHLEVEL* = 11         # SDL.h constants
-  INIT_TIMER* = 0x00000001
-  INIT_AUDIO* = 0x00000010
-  INIT_VIDEO* = 0x00000020
-  INIT_CDROM* = 0x00000100
-  INIT_JOYSTICK* = 0x00000200
-  INIT_NOPARACHUTE* = 0x00100000 # Don't catch fatal signals
-  INIT_EVENTTHREAD* = 0x01000000 # Not supported on all OS's
-  INIT_EVERYTHING* = 0x0000FFFF # SDL_error.h constants
-  ERR_MAX_STRLEN* = 128
-  ERR_MAX_ARGS* = 5           # SDL_types.h constants
-  PRESSED* = 0x00000001
-  RELEASED* = 0x00000000      # SDL_timer.h constants
-                              # This is the OS scheduler timeslice, in milliseconds
-  TIMESLICE* = 10             # This is the maximum resolution of the SDL timer on all platforms
-  TIMER_RESOLUTION* = 10      # Experimentally determined
-                              # SDL_audio.h constants
-  AUDIO_U8* = 0x00000008      # Unsigned 8-bit samples
-  AUDIO_S8* = 0x00008008      # Signed 8-bit samples
-  AUDIO_U16LSB* = 0x00000010  # Unsigned 16-bit samples
-  AUDIO_S16LSB* = 0x00008010  # Signed 16-bit samples
-  AUDIO_U16MSB* = 0x00001010  # As above, but big-endian byte order
-  AUDIO_S16MSB* = 0x00009010  # As above, but big-endian byte order
-  AUDIO_U16* = AUDIO_U16LSB
-  AUDIO_S16* = AUDIO_S16LSB   # SDL_cdrom.h constants
-                              # The maximum number of CD-ROM tracks on a disk
-  MAX_TRACKS* = 99            # The types of CD-ROM track possible
-  AUDIO_TRACK* = 0x00000000
-  DATA_TRACK* = 0x00000004    # Conversion functions from frames to Minute/Second/Frames and vice versa
-  CD_FPS* = 75                # SDL_byteorder.h constants
-                              # The two types of endianness
-  LIL_ENDIAN* = 1234
-  BIG_ENDIAN* = 4321
-
-when cpuEndian == littleEndian: 
-  const 
-    BYTEORDER* = LIL_ENDIAN   # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16LSB
-    AUDIO_S16SYS* = AUDIO_S16LSB
-else: 
-  const 
-    BYTEORDER* = BIG_ENDIAN   # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16MSB
-    AUDIO_S16SYS* = AUDIO_S16MSB
-const 
-  MIX_MAXVOLUME* = 128        # SDL_joystick.h constants
-  MAX_JOYSTICKS* = 2          # only 2 are supported in the multimedia API
-  MAX_AXES* = 6               # each joystick can have up to 6 axes
-  MAX_BUTTONS* = 32           # and 32 buttons
-  AXIS_MIN* = - 32768         # minimum value for axis coordinate
-  AXIS_MAX* = 32767           # maximum value for axis coordinate
-  JOY_AXIS_THRESHOLD* = (toFloat((AXIS_MAX) - (AXIS_MIN)) / 100.000) # 1% motion
-  HAT_CENTERED* = 0x00000000
-  HAT_UP* = 0x00000001
-  HAT_RIGHT* = 0x00000002
-  HAT_DOWN* = 0x00000004
-  HAT_LEFT* = 0x00000008
-  HAT_RIGHTUP* = HAT_RIGHT or HAT_UP
-  HAT_RIGHTDOWN* = HAT_RIGHT or HAT_DOWN
-  HAT_LEFTUP* = HAT_LEFT or HAT_UP
-  HAT_LEFTDOWN* = HAT_LEFT or HAT_DOWN # SDL_events.h constants
-
-type 
-  EventKind* = enum          # kind of an SDL event
-    NOEVENT = 0,              # Unused (do not remove)
-    ACTIVEEVENT = 1,          # Application loses/gains visibility
-    KEYDOWN = 2,              # Keys pressed
-    KEYUP = 3,                # Keys released
-    MOUSEMOTION = 4,          # Mouse moved
-    MOUSEBUTTONDOWN = 5,      # Mouse button pressed
-    MOUSEBUTTONUP = 6,        # Mouse button released
-    JOYAXISMOTION = 7,        # Joystick axis motion
-    JOYBALLMOTION = 8,        # Joystick trackball motion
-    JOYHATMOTION = 9,         # Joystick hat position change
-    JOYBUTTONDOWN = 10,       # Joystick button pressed
-    JOYBUTTONUP = 11,         # Joystick button released
-    QUITEV = 12,              # User-requested quit ( Changed due to procedure conflict )
-    SYSWMEVENT = 13,          # System specific event
-    EVENT_RESERVEDA = 14,     # Reserved for future use..
-    EVENT_RESERVED = 15,      # Reserved for future use..
-    VIDEORESIZE = 16,         # User resized video mode
-    VIDEOEXPOSE = 17,         # Screen needs to be redrawn
-    EVENT_RESERVED2 = 18,     # Reserved for future use..
-    EVENT_RESERVED3 = 19,     # Reserved for future use..
-    EVENT_RESERVED4 = 20,     # Reserved for future use..
-    EVENT_RESERVED5 = 21,     # Reserved for future use..
-    EVENT_RESERVED6 = 22,     # Reserved for future use..
-    EVENT_RESERVED7 = 23,     # Reserved for future use..
-                              # Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
-    USEREVENT = 24 # This last event is only for bounding internal arrays
-                   # It is the number of bits in the event mask datatype -- int32
-{.deprecated: [TEventKind: EventKind].}
-
-const 
-  NUMEVENTS* = 32
-  ALLEVENTS* = 0xFFFFFFFF
-  ACTIVEEVENTMASK* = 1 shl ord(ACTIVEEVENT)
-  KEYDOWNMASK* = 1 shl ord(KEYDOWN)
-  KEYUPMASK* = 1 shl ord(KEYUP)
-  MOUSEMOTIONMASK* = 1 shl ord(MOUSEMOTION)
-  MOUSEBUTTONDOWNMASK* = 1 shl ord(MOUSEBUTTONDOWN)
-  MOUSEBUTTONUPMASK* = 1 shl ord(MOUSEBUTTONUP)
-  MOUSEEVENTMASK* = 1 shl ord(MOUSEMOTION) or 1 shl ord(MOUSEBUTTONDOWN) or
-      1 shl ord(MOUSEBUTTONUP)
-  JOYAXISMOTIONMASK* = 1 shl ord(JOYAXISMOTION)
-  JOYBALLMOTIONMASK* = 1 shl ord(JOYBALLMOTION)
-  JOYHATMOTIONMASK* = 1 shl ord(JOYHATMOTION)
-  JOYBUTTONDOWNMASK* = 1 shl ord(JOYBUTTONDOWN)
-  JOYBUTTONUPMASK* = 1 shl ord(JOYBUTTONUP)
-  JOYEVENTMASK* = 1 shl ord(JOYAXISMOTION) or 1 shl ord(JOYBALLMOTION) or
-      1 shl ord(JOYHATMOTION) or 1 shl ord(JOYBUTTONDOWN) or
-      1 shl ord(JOYBUTTONUP)
-  VIDEORESIZEMASK* = 1 shl ord(VIDEORESIZE)
-  QUITMASK* = 1 shl ord(QUITEV)
-  SYSWMEVENTMASK* = 1 shl ord(SYSWMEVENT)
-  QUERY* = - 1
-  IGNORE* = 0
-  DISABLE* = 0
-  ENABLE* = 1                 #SDL_keyboard.h constants
-                              # This is the mask which refers to all hotkey bindings
-  ALL_HOTKEYS* = 0xFFFFFFFF # Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
-                            #  'delay' is the initial delay in ms between the time when a key is
-                            #  pressed, and keyboard repeat begins.
-                            #  'interval' is the time in ms between keyboard repeat events.
-  DEFAULT_REPEAT_DELAY* = 500
-  DEFAULT_REPEAT_INTERVAL* = 30 # The keyboard syms have been cleverly chosen to map to ASCII
-  K_UNKNOWN* = 0
-  K_FIRST* = 0
-  K_BACKSPACE* = 8
-  K_TAB* = 9
-  K_CLEAR* = 12
-  K_RETURN* = 13
-  K_PAUSE* = 19
-  K_ESCAPE* = 27
-  K_SPACE* = 32
-  K_EXCLAIM* = 33
-  K_QUOTEDBL* = 34
-  K_HASH* = 35
-  K_DOLLAR* = 36
-  K_AMPERSAND* = 38
-  K_QUOTE* = 39
-  K_LEFTPAREN* = 40
-  K_RIGHTPAREN* = 41
-  K_ASTERISK* = 42
-  K_PLUS* = 43
-  K_COMMA* = 44
-  K_MINUS* = 45
-  K_PERIOD* = 46
-  K_SLASH* = 47
-  K_0* = 48
-  K_1* = 49
-  K_2* = 50
-  K_3* = 51
-  K_4* = 52
-  K_5* = 53
-  K_6* = 54
-  K_7* = 55
-  K_8* = 56
-  K_9* = 57
-  K_COLON* = 58
-  K_SEMICOLON* = 59
-  K_LESS* = 60
-  K_EQUALS* = 61
-  K_GREATER* = 62
-  K_QUESTION* = 63
-  K_AT* = 64                  # Skip uppercase letters
-  K_LEFTBRACKET* = 91
-  K_BACKSLASH* = 92
-  K_RIGHTBRACKET* = 93
-  K_CARET* = 94
-  K_UNDERSCORE* = 95
-  K_BACKQUOTE* = 96
-  K_a* = 97
-  K_b* = 98
-  K_c* = 99
-  K_d* = 100
-  K_e* = 101
-  K_f* = 102
-  K_g* = 103
-  K_h* = 104
-  K_i* = 105
-  K_j* = 106
-  K_k* = 107
-  K_l* = 108
-  K_m* = 109
-  K_n* = 110
-  K_o* = 111
-  K_p* = 112
-  K_q* = 113
-  K_r* = 114
-  K_s* = 115
-  K_t* = 116
-  K_u* = 117
-  K_v* = 118
-  K_w* = 119
-  K_x* = 120
-  K_y* = 121
-  K_z* = 122
-  K_DELETE* = 127             # End of ASCII mapped keysyms
-                              # International keyboard syms
-  K_WORLD_0* = 160            # 0xA0
-  K_WORLD_1* = 161
-  K_WORLD_2* = 162
-  K_WORLD_3* = 163
-  K_WORLD_4* = 164
-  K_WORLD_5* = 165
-  K_WORLD_6* = 166
-  K_WORLD_7* = 167
-  K_WORLD_8* = 168
-  K_WORLD_9* = 169
-  K_WORLD_10* = 170
-  K_WORLD_11* = 171
-  K_WORLD_12* = 172
-  K_WORLD_13* = 173
-  K_WORLD_14* = 174
-  K_WORLD_15* = 175
-  K_WORLD_16* = 176
-  K_WORLD_17* = 177
-  K_WORLD_18* = 178
-  K_WORLD_19* = 179
-  K_WORLD_20* = 180
-  K_WORLD_21* = 181
-  K_WORLD_22* = 182
-  K_WORLD_23* = 183
-  K_WORLD_24* = 184
-  K_WORLD_25* = 185
-  K_WORLD_26* = 186
-  K_WORLD_27* = 187
-  K_WORLD_28* = 188
-  K_WORLD_29* = 189
-  K_WORLD_30* = 190
-  K_WORLD_31* = 191
-  K_WORLD_32* = 192
-  K_WORLD_33* = 193
-  K_WORLD_34* = 194
-  K_WORLD_35* = 195
-  K_WORLD_36* = 196
-  K_WORLD_37* = 197
-  K_WORLD_38* = 198
-  K_WORLD_39* = 199
-  K_WORLD_40* = 200
-  K_WORLD_41* = 201
-  K_WORLD_42* = 202
-  K_WORLD_43* = 203
-  K_WORLD_44* = 204
-  K_WORLD_45* = 205
-  K_WORLD_46* = 206
-  K_WORLD_47* = 207
-  K_WORLD_48* = 208
-  K_WORLD_49* = 209
-  K_WORLD_50* = 210
-  K_WORLD_51* = 211
-  K_WORLD_52* = 212
-  K_WORLD_53* = 213
-  K_WORLD_54* = 214
-  K_WORLD_55* = 215
-  K_WORLD_56* = 216
-  K_WORLD_57* = 217
-  K_WORLD_58* = 218
-  K_WORLD_59* = 219
-  K_WORLD_60* = 220
-  K_WORLD_61* = 221
-  K_WORLD_62* = 222
-  K_WORLD_63* = 223
-  K_WORLD_64* = 224
-  K_WORLD_65* = 225
-  K_WORLD_66* = 226
-  K_WORLD_67* = 227
-  K_WORLD_68* = 228
-  K_WORLD_69* = 229
-  K_WORLD_70* = 230
-  K_WORLD_71* = 231
-  K_WORLD_72* = 232
-  K_WORLD_73* = 233
-  K_WORLD_74* = 234
-  K_WORLD_75* = 235
-  K_WORLD_76* = 236
-  K_WORLD_77* = 237
-  K_WORLD_78* = 238
-  K_WORLD_79* = 239
-  K_WORLD_80* = 240
-  K_WORLD_81* = 241
-  K_WORLD_82* = 242
-  K_WORLD_83* = 243
-  K_WORLD_84* = 244
-  K_WORLD_85* = 245
-  K_WORLD_86* = 246
-  K_WORLD_87* = 247
-  K_WORLD_88* = 248
-  K_WORLD_89* = 249
-  K_WORLD_90* = 250
-  K_WORLD_91* = 251
-  K_WORLD_92* = 252
-  K_WORLD_93* = 253
-  K_WORLD_94* = 254
-  K_WORLD_95* = 255           # 0xFF
-                              # Numeric keypad
-  K_KP0* = 256
-  K_KP1* = 257
-  K_KP2* = 258
-  K_KP3* = 259
-  K_KP4* = 260
-  K_KP5* = 261
-  K_KP6* = 262
-  K_KP7* = 263
-  K_KP8* = 264
-  K_KP9* = 265
-  K_KP_PERIOD* = 266
-  K_KP_DIVIDE* = 267
-  K_KP_MULTIPLY* = 268
-  K_KP_MINUS* = 269
-  K_KP_PLUS* = 270
-  K_KP_ENTER* = 271
-  K_KP_EQUALS* = 272          # Arrows + Home/End pad
-  K_UP* = 273
-  K_DOWN* = 274
-  K_RIGHT* = 275
-  K_LEFT* = 276
-  K_INSERT* = 277
-  K_HOME* = 278
-  K_END* = 279
-  K_PAGEUP* = 280
-  K_PAGEDOWN* = 281           # Function keys
-  K_F1* = 282
-  K_F2* = 283
-  K_F3* = 284
-  K_F4* = 285
-  K_F5* = 286
-  K_F6* = 287
-  K_F7* = 288
-  K_F8* = 289
-  K_F9* = 290
-  K_F10* = 291
-  K_F11* = 292
-  K_F12* = 293
-  K_F13* = 294
-  K_F14* = 295
-  K_F15* = 296                # Key state modifier keys
-  K_NUMLOCK* = 300
-  K_CAPSLOCK* = 301
-  K_SCROLLOCK* = 302
-  K_RSHIFT* = 303
-  K_LSHIFT* = 304
-  K_RCTRL* = 305
-  K_LCTRL* = 306
-  K_RALT* = 307
-  K_LALT* = 308
-  K_RMETA* = 309
-  K_LMETA* = 310
-  K_LSUPER* = 311             # Left "Windows" key
-  K_RSUPER* = 312             # Right "Windows" key
-  K_MODE* = 313               # "Alt Gr" key
-  K_COMPOSE* = 314            # Multi-key compose key
-                              # Miscellaneous function keys
-  K_HELP* = 315
-  K_PRINT* = 316
-  K_SYSREQ* = 317
-  K_BREAK* = 318
-  K_MENU* = 319
-  K_POWER* = 320              # Power Macintosh power key
-  K_EURO* = 321               # Some european keyboards
-  K_GP2X_UP* = 0
-  K_GP2X_UPLEFT* = 1
-  K_GP2X_LEFT* = 2
-  K_GP2X_DOWNLEFT* = 3
-  K_GP2X_DOWN* = 4
-  K_GP2X_DOWNRIGHT* = 5
-  K_GP2X_RIGHT* = 6
-  K_GP2X_UPRIGHT* = 7
-  K_GP2X_START* = 8
-  K_GP2X_SELECT* = 9
-  K_GP2X_L* = 10
-  K_GP2X_R* = 11
-  K_GP2X_A* = 12
-  K_GP2X_B* = 13
-  K_GP2X_Y* = 14
-  K_GP2X_X* = 15
-  K_GP2X_VOLUP* = 16
-  K_GP2X_VOLDOWN* = 17
-  K_GP2X_CLICK* = 18
-
-const                         # Enumeration of valid key mods (possibly OR'd together)
-  KMOD_NONE* = 0x00000000
-  KMOD_LSHIFT* = 0x00000001
-  KMOD_RSHIFT* = 0x00000002
-  KMOD_LCTRL* = 0x00000040
-  KMOD_RCTRL* = 0x00000080
-  KMOD_LALT* = 0x00000100
-  KMOD_RALT* = 0x00000200
-  KMOD_LMETA* = 0x00000400
-  KMOD_RMETA* = 0x00000800
-  KMOD_NUM* = 0x00001000
-  KMOD_CAPS* = 0x00002000
-  KMOD_MODE* = 44000
-  KMOD_RESERVED* = 0x00008000
-  KMOD_CTRL* = (KMOD_LCTRL or KMOD_RCTRL)
-  KMOD_SHIFT* = (KMOD_LSHIFT or KMOD_RSHIFT)
-  KMOD_ALT* = (KMOD_LALT or KMOD_RALT)
-  KMOD_META* = (KMOD_LMETA or KMOD_RMETA) #SDL_video.h constants
-                                          # Transparency definitions: These define alpha as the opacity of a surface */
-  ALPHA_OPAQUE* = 255
-  ALPHA_TRANSPARENT* = 0 # These are the currently supported flags for the SDL_surface
-                         # Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
-  SWSURFACE* = 0x00000000     # Surface is in system memory
-  HWSURFACE* = 0x00000001     # Surface is in video memory
-  ASYNCBLIT* = 0x00000004     # Use asynchronous blits if possible
-                              # Available for SDL_SetVideoMode()
-  ANYFORMAT* = 0x10000000     # Allow any video depth/pixel-format
-  HWPALETTE* = 0x20000000     # Surface has exclusive palette
-  DOUBLEBUF* = 0x40000000     # Set up double-buffered video mode
-  FULLSCREEN* = 0x80000000    # Surface is a full screen display
-  OPENGL* = 0x00000002        # Create an OpenGL rendering context
-  OPENGLBLIT* = 0x00000002    # Create an OpenGL rendering context
-  RESIZABLE* = 0x00000010     # This video mode may be resized
-  NOFRAME* = 0x00000020       # No window caption or edge frame
-                              # Used internally (read-only)
-  HWACCEL* = 0x00000100       # Blit uses hardware acceleration
-  SRCCOLORKEY* = 0x00001000   # Blit uses a source color key
-  RLEACCELOK* = 0x00002000    # Private flag
-  RLEACCEL* = 0x00004000      # Colorkey blit is RLE accelerated
-  SRCALPHA* = 0x00010000      # Blit uses source alpha blending
-  SRCCLIPPING* = 0x00100000   # Blit uses source clipping
-  PREALLOC* = 0x01000000 # Surface uses preallocated memory
-                         # The most common video overlay formats.
-                         #    For an explanation of these pixel formats, see:
-                         #    http://www.webartz.com/fourcc/indexyuv.htm
-                         #
-                         #   For information on the relationship between color spaces, see:
-                         #
-                         #   
-                         #   http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
-  YV12_OVERLAY* = 0x32315659  # Planar mode: Y + V + U  (3 planes)
-  IYUV_OVERLAY* = 0x56555949  # Planar mode: Y + U + V  (3 planes)
-  YUY2_OVERLAY* = 0x32595559  # Packed mode: Y0+U0+Y1+V0 (1 plane)
-  UYVY_OVERLAY* = 0x59565955  # Packed mode: U0+Y0+V0+Y1 (1 plane)
-  YVYU_OVERLAY* = 0x55595659  # Packed mode: Y0+V0+Y1+U0 (1 plane)
-                              # flags for SDL_SetPalette()
-  LOGPAL* = 0x00000001
-  PHYSPAL* = 0x00000002 #SDL_mouse.h constants
-                        # Used as a mask when testing buttons in buttonstate
-                        #    Button 1:	Left mouse button
-                        #    Button 2:	Middle mouse button
-                        #    Button 3:	Right mouse button
-                        #    Button 4:	Mouse Wheel Up
-                        #    Button 5:	Mouse Wheel Down
-                        #
-  BUTTON_LEFT* = 1
-  BUTTON_MIDDLE* = 2
-  BUTTON_RIGHT* = 3
-  BUTTON_WHEELUP* = 4
-  BUTTON_WHEELDOWN* = 5
-  BUTTON_LMASK* = PRESSED shl (BUTTON_LEFT - 1)
-  BUTTON_MMASK* = PRESSED shl (BUTTON_MIDDLE - 1)
-  BUTTON_RMask* = PRESSED shl (BUTTON_RIGHT - 1) # SDL_active.h constants
-                                                 # The available application states
-  APPMOUSEFOCUS* = 0x00000001 # The app has mouse coverage
-  APPINPUTFOCUS* = 0x00000002 # The app has input focus
-  APPACTIVE* = 0x00000004 # The application is active
-                          # SDL_mutex.h constants
-                          # Synchronization functions which can time out return this value
-                          #  they time out.
-  MUTEX_TIMEDOUT* = 1         # This is the timeout value which corresponds to never time out
-  MUTEX_MAXWAIT* = not int(0)
-  GRAB_QUERY* = - 1
-  GRAB_OFF* = 0
-  GRAB_ON* = 1                #SDL_GRAB_FULLSCREEN // Used internally
-
-type 
-  Handle* = int               #SDL_types.h types
-                              # Basic data types
-  Bool* = enum
-    sdlFALSE, sdlTRUE
-  PUInt8Array* = ptr UInt8Array
-  UInt8Array* = array[0..high(int) shr 1, byte]
-  PUInt16* = ptr uint16
-  PUInt32* = ptr uint32
-  PUInt64* = ptr UInt64
-  UInt64*{.final.} = object 
-    hi*: int32
-    lo*: int32
-
-  PSInt64* = ptr SInt64
-  SInt64*{.final.} = object 
-    hi*: int32
-    lo*: int32
-
-  GrabMode* = int32         # SDL_error.h types
-  ErrorCode* = enum 
-    ENOMEM, EFREAD, EFWRITE, EFSEEK, LASTERROR
-  Arg*{.final.} = object 
-    buf*: array[0..ERR_MAX_STRLEN - 1, int8]
-
-  Perror* = ptr Error
-  Error*{.final.} = object   # This is a numeric value corresponding to the current error
-                             # SDL_rwops.h types
-                             # This is the read/write operation structure -- very basic
-                             # some helper types to handle the unions
-                             # "packed" is only guessed
-    error*: int # This is a key used to index into a language hashtable containing
-                #       internationalized versions of the SDL error messages.  If the key
-                #       is not in the hashtable, or no hashtable is available, the key is
-                #       used directly as an error message format string.
-    key*: array[0..ERR_MAX_STRLEN - 1, int8] # These are the arguments for the error functions
-    argc*: int
-    args*: array[0..ERR_MAX_ARGS - 1, Arg]
-
-  Stdio*{.final.} = object 
-    autoclose*: int           # FILE * is only defined in Kylix so we use a simple pointer
-    fp*: pointer
-
-  Mem*{.final.} = object 
-    base*: ptr byte
-    here*: ptr byte
-    stop*: ptr byte
-
-  PRWops* = ptr RWops        # now the pointer to function types
-  Seek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.}
-  Read* = proc (context: PRWops, thePtr: pointer, size: int, maxnum: int): int{.
-      cdecl.}
-  Write* = proc (context: PRWops, thePtr: pointer, size: int, num: int): int{.
-      cdecl.}
-  Close* = proc (context: PRWops): int{.cdecl.} # the variant record itself
-  RWops*{.final.} = object 
-    seek*: Seek
-    read*: Read
-    write*: Write
-    closeFile*: Close         # a keyword as name is not allowed
-                              # be warned! structure alignment may arise at this point
-    theType*: cint
-    mem*: Mem
-  
-                              # SDL_timer.h types
-                              # Function prototype for the timer callback function
-  TimerCallback* = proc (interval: int32): int32{.cdecl.}
-  NewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.}
-
-  PTimerID* = ptr TimerID
-  TimerID*{.final.} = object 
-    interval*: int32
-    callback*: NewTimerCallback
-    param*: pointer
-    lastAlarm*: int32
-    next*: PTimerID
-
-  AudioSpecCallback* = proc (userdata: pointer, stream: ptr byte, length: int){.
-      cdecl.}                 # SDL_audio.h types
-                              # The calculated values in this structure are calculated by SDL_OpenAudio()
-  PAudioSpec* = ptr AudioSpec
-  AudioSpec*{.final.} = object  # A structure to hold a set of audio conversion filters and buffers
-    freq*: int                # DSP frequency -- samples per second
-    format*: uint16           # Audio data format
-    channels*: byte          # Number of channels: 1 mono, 2 stereo
-    silence*: byte           # Audio buffer silence value (calculated)
-    samples*: uint16          # Audio buffer size in samples
-    padding*: uint16          # Necessary for some compile environments
-    size*: int32 # Audio buffer size in bytes (calculated)
-                 # This function is called when the audio device needs more data.
-                 # 'stream' is a pointer to the audio data buffer
-                 # 'len' is the length of that buffer in bytes.
-                 # Once the callback returns, the buffer will no longer be valid.
-                 # Stereo samples are stored in a LRLRLR ordering.
-    callback*: AudioSpecCallback
-    userdata*: pointer
-
-  PAudioCVT* = ptr AudioCVT
-  PAudioCVTFilter* = ptr AudioCVTFilter
-  AudioCVTFilter*{.final.} = object 
-    cvt*: PAudioCVT
-    format*: uint16
-
-  PAudioCVTFilterArray* = ptr AudioCVTFilterArray
-  AudioCVTFilterArray* = array[0..9, PAudioCVTFilter]
-  AudioCVT*{.final.} = object 
-    needed*: int              # Set to 1 if conversion possible
-    srcFormat*: uint16       # Source audio format
-    dstFormat*: uint16       # Target audio format
-    rateIncr*: float64       # Rate conversion increment
-    buf*: ptr byte              # Buffer to hold entire audio data
-    length*: int              # Length of original audio buffer
-    lenCvt*: int             # Length of converted audio buffer
-    lenMult*: int            # buffer must be len*len_mult big
-    lenRatio*: float64       # Given len, final size is len*len_ratio
-    filters*: AudioCVTFilterArray
-    filterIndex*: int        # Current audio conversion function
-  
-  AudioStatus* = enum        # SDL_cdrom.h types
-    AUDIO_STOPPED, AUDIO_PLAYING, AUDIO_PAUSED
-  CDStatus* = enum 
-    CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED
-  PCDTrack* = ptr CDTrack
-  CDTrack*{.final.} = object  # This structure is only current as of the last call to SDL_CDStatus()
-    id*: byte                # Track number
-    theType*: byte           # Data or audio track
-    unused*: uint16
-    len*: int32              # Length, in frames, of this track
-    offset*: int32           # Offset, in frames, from start of disk
-  
-  PCD* = ptr CD
-  CD*{.final.} = object      #SDL_joystick.h types
-    id*: int                  # Private drive identifier
-    status*: CDStatus         # Current drive status
-                              # The rest of this structure is only valid if there's a CD in drive
-    numtracks*: int           # Number of tracks on disk
-    curTrack*: int            # Current track position
-    curFrame*: int           # Current frame offset within current track
-    track*: array[0..MAX_TRACKS, CDTrack]
-
-  PTransAxis* = ptr TransAxis
-  TransAxis*{.final.} = object  # The private structure used to keep track of a joystick
-    offset*: int
-    scale*: float32
-
-  PJoystickHwdata* = ptr JoystickHwdata
-  Joystick_hwdata*{.final.} = object  # joystick ID
-    id*: int                  # values used to translate device-specific coordinates into  SDL-standard ranges
-    transaxis*: array[0..5, TransAxis]
-
-  PBallDelta* = ptr BallDelta
-  BallDelta*{.final.} = object  # Current ball motion deltas
-                                 # The SDL joystick structure
-    dx*: int
-    dy*: int
-
-  PJoystick* = ptr Joystick
-  Joystick*{.final.} = object  # SDL_verion.h types
-    index*: byte             # Device index
-    name*: cstring            # Joystick name - system dependent
-    naxes*: int               # Number of axis controls on the joystick
-    axes*: PUInt16            # Current axis states
-    nhats*: int               # Number of hats on the joystick
-    hats*: ptr byte             # Current hat states
-    nballs*: int              # Number of trackballs on the joystick
-    balls*: PBallDelta        # Current ball motion deltas
-    nbuttons*: int            # Number of buttons on the joystick
-    buttons*: ptr byte          # Current button states
-    hwdata*: PJoystickHwdata # Driver dependent information
-    refCount*: int           # Reference count for multiple opens
-  
-  Pversion* = ptr Version
-  Version*{.final.} = object  # SDL_keyboard.h types
-    major*: byte
-    minor*: byte
-    patch*: byte
-
-  Key* = int32
-  Mod* = int32
-  PKeySym* = ptr KeySym
-  KeySym*{.final.} = object  # SDL_events.h types
-                              #Checks the event queue for messages and optionally returns them.
-                              #   If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-                              #   the back of the event queue.
-                              #   If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-                              #   of the event queue, matching 'mask', will be returned and will not
-                              #   be removed from the queue.
-                              #   If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-                              #   of the event queue, matching 'mask', will be returned and will be
-                              #   removed from the queue.
-                              #   This function returns the number of events actually stored, or -1
-                              #   if there was an error.  This function is thread-safe.
-    scancode*: byte           # hardware specific scancode
-    sym*: Key                 # SDL virtual keysym
-    modifier*: Mod            # current key modifiers
-    unicode*: uint16          # translated character
-  
-  EventAction* = enum        # Application visibility event structure
-    ADDEVENT, PEEKEVENT, GETEVENT
-
-  PActiveEvent* = ptr TActiveEvent
-  TActiveEvent*{.final.} = object  # SDL_ACTIVEEVENT
-                                   # Keyboard event structure
-    kind*: EventKind
-    gain*: byte              # Whether given states were gained or lost (1/0)
-    state*: byte             # A mask of the focus states
-  
-  PKeyboardEvent* = ptr KeyboardEvent
-  KeyboardEvent*{.final.} = object  # SDL_KEYDOWN or SDL_KEYUP
-                                     # Mouse motion event structure
-    kind*: EventKind
-    which*: byte             # The keyboard device index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-    keysym*: KeySym
-
-  PMouseMotionEvent* = ptr MouseMotionEvent
-  MouseMotionEvent*{.final.} = object  # SDL_MOUSEMOTION
-                                        # Mouse button event structure
-    kind*: EventKind
-    which*: byte             # The mouse device index
-    state*: byte             # The current button state
-    x*, y*: uint16            # The X/Y coordinates of the mouse
-    xrel*: int16             # The relative motion in the X direction
-    yrel*: int16             # The relative motion in the Y direction
-  
-  PMouseButtonEvent* = ptr MouseButtonEvent
-  MouseButtonEvent*{.final.} = object  # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
-                                        # Joystick axis motion event structure
-    kind*: EventKind
-    which*: byte             # The mouse device index
-    button*: byte            # The mouse button index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-    x*: uint16                # The X coordinates of the mouse at press time
-    y*: uint16                # The Y coordinates of the mouse at press time
-  
-  PJoyAxisEvent* = ptr JoyAxisEvent
-  JoyAxisEvent*{.final.} = object  # SDL_JOYAXISMOTION
-                                    # Joystick trackball motion event structure
-    kind*: EventKind
-    which*: byte             # The joystick device index
-    axis*: byte              # The joystick axis index
-    value*: int16            # The axis value (range: -32768 to 32767)
-  
-  PJoyBallEvent* = ptr JoyBallEvent
-  JoyBallEvent*{.final.} = object  # SDL_JOYAVBALLMOTION
-                                    # Joystick hat position change event structure
-    kind*: EventKind
-    which*: byte             # The joystick device index
-    ball*: byte              # The joystick trackball index
-    xrel*: int16             # The relative motion in the X direction
-    yrel*: int16             # The relative motion in the Y direction
-  
-  PJoyHatEvent* = ptr JoyHatEvent
-  JoyHatEvent*{.final.} = object  # SDL_JOYHATMOTION */
-                                   # Joystick button event structure
-    kind*: EventKind
-    which*: byte             # The joystick device index */
-    hat*: byte               # The joystick hat index */
-    value*: byte             # The hat position value:
-                             # 8   1   2
-                             # 7   0   3
-                             # 6   5   4
-                             # Note that zero means the POV is centered.
-  
-  PJoyButtonEvent* = ptr JoyButtonEvent
-  JoyButtonEvent*{.final.} = object  # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
-                                      # The "window resized" event
-                                      # When you get this event, you are
-                                      # responsible for setting a new video
-                                      # mode with the new width and height.
-    kind*: EventKind
-    which*: byte             # The joystick device index
-    button*: byte            # The joystick button index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-  
-  PResizeEvent* = ptr ResizeEvent
-  ResizeEvent*{.final.} = object   # SDL_VIDEORESIZE
-                                   # A user-defined event type
-    kind*: EventKind
-    w*: cint                   # New width
-    h*: cint                   # New height
-  
-  PUserEvent* = ptr TUserEvent
-  TUserEvent*{.final.} = object  # SDL_USEREVENT through SDL_NUMEVENTS-1
-    kind*: EventKind
-    code*: cint               # User defined event code
-    data1*: pointer           # User defined data pointer
-    data2*: pointer           # User defined data pointer 
-  
-{.deprecated: [THandle: Handle, TEventAction: EventAction, TKey: Key, TArg: Arg,
-              TKeySym: KeySym, TKeyboardEvent: KeyboardEvent, TError: Error,
-              TWrite: Write, TBool: Bool, TUInt8Array: UInt8Array,
-              TGrabMode: GrabMode, Terrorcode: Errorcode, TStdio: Stdio,
-              TMem: Mem, TSeek: Seek, TRead: Read, TClose: Close,
-              TTimerCallback: TimerCallback, TNewTimerCallback: NewTimerCallback,
-              TTimerID: TimerID, TAudioSpecCallback: AudioSpecCallback,
-              TAudioSpec: AudioSpec, TAudioCVTFilter: AudioCVTFilter,
-              TAudioCVTFilterArray: AudioCVTFilterArray, TAudioCVT: AudioCVT,
-              TAudioStatus: AudioStatus, TCDStatus: CDStatus, TCDTrack: CDTrack,
-              TCD: CD, TTransAxis: TransAxis, TJoystick_hwdata: Joystick_hwdata,
-              TJoystick: Joystick, TJoyAxisEvent: JoyAxisEvent, TRWops: RWops,
-              TJoyBallEvent: JoyBallEvent, TJoyHatEvent: JoyHatEvent,
-              TJoyButtonEvent: JoyButtonEvent, TBallDelta: BallDelta,
-              Tversion: Version, TMod: Mod,
-              # TActiveEvent: ActiveEvent, # Naming conflict when we drop the `T`
-              TMouseMotionEvent: MouseMotionEvent, TMouseButtonEvent: MouseButtonEvent,
-              TResizeEvent: ResizeEvent,
-              # TUserEvent: UserEvent # Naming conflict when we drop the `T`
-              ].}
-
-when defined(Unix):
-  type                        #These are the various supported subsystems under UNIX
-    SysWm* = enum 
-      SYSWM_X11
-  {.deprecated: [TSysWm: SysWm].}
-when defined(WINDOWS):
-  type 
-    PSysWMmsg* = ptr SysWMmsg
-    SysWMmsg*{.final.} = object 
-      version*: Version
-      hwnd*: Handle          # The window for the message
-      msg*: int               # The type of message
-      wParam*: int32         # WORD message parameter
-      lParam*: int32          # LONG message parameter
-  {.deprecated: [TSysWMmsg: SysWMmsg].}
-    
-elif defined(Unix): 
-  type                        # The Linux custom event structure
-    PSysWMmsg* = ptr SysWMmsg
-    SysWMmsg*{.final.} = object 
-      version*: Version
-      subsystem*: SysWm
-      when false: 
-          event*: TXEvent
-  {.deprecated: [TSysWMmsg: SysWMmsg].}
-
-    
-else: 
-  type                        # The generic custom event structure
-    PSysWMmsg* = ptr SysWMmsg
-    SysWMmsg*{.final.} = object 
-      version*: Version
-      data*: int
-  {.deprecated: [TSysWMmsg: SysWMmsg].}
-
-# The Windows custom window manager information structure
-
-when defined(WINDOWS): 
-  type 
-    PSysWMinfo* = ptr SysWMinfo
-    SysWMinfo*{.final.} = object 
-      version*: Version
-      window*: Handle        # The display window
-  {.deprecated: [TSysWMinfo: SysWMinfo].}
-    
-elif defined(Unix): 
-  type 
-    X11*{.final.} = object 
-      when false: 
-          display*: PDisplay  # The X11 display
-          window*: Window     # The X11 display window
-                              # These locking functions should be called around
-                              # any X11 functions using the display variable.
-                              # They lock the event thread, so should not be
-                              # called around event functions or from event filters.
-          lock_func*: pointer
-          unlock_func*: pointer # Introduced in SDL 1.0.2
-          fswindow*: Window   # The X11 fullscreen window
-          wmwindow*: Window   # The X11 managed input window
-  {.deprecated: [TX11: X11].}
-        
-    
-  type 
-    PSysWMinfo* = ptr SysWMinfo
-    SysWMinfo*{.final.} = object 
-      version*: Version
-      subsystem*: SysWm
-      X11*: X11
-  {.deprecated: [TSysWMinfo: SysWMinfo].}
-
-else: 
-  type # The generic custom window manager information structure
-    PSysWMinfo* = ptr SysWMinfo
-    SysWMinfo*{.final.} = object 
-      version*: Version
-      data*: int
-  {.deprecated: [TSysWMinfo: SysWMinfo].}
-
-type 
-  PSysWMEvent* = ptr TSysWMEvent
-  TSysWMEvent*{.final.} = object 
-    kind*: EventKind
-    msg*: PSysWMmsg
-
-  PExposeEvent* = ptr ExposeEvent
-  ExposeEvent*{.final.} = object
-    kind*: EventKind
-
-  PQuitEvent* = ptr QuitEvent
-  QuitEvent*{.final.} = object
-    kind*: EventKind
-
-  PEvent* = ptr Event
-  Event*{.final.} = object  
-    kind*: EventKind
-    pad: array[0..19, byte]
-  
-  EventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types
-                                                     # Useful data types
-  PPSDL_Rect* = ptr PRect
-  PRect* = ptr Rect
-  Rect*{.final.} = object 
-    x*, y*: int16
-    w*, h*: uint16
-
-#  Rect* = TRect
-  PColor* = ptr Color
-  Color*{.final.} = object 
-    r*: byte
-    g*: byte
-    b*: byte
-    unused*: byte
-
-  PColorArray* = ptr ColorArray
-  ColorArray* = array[0..65000, Color]
-  PPalette* = ptr Palette
-  Palette*{.final.} = object  # Everything in the pixel format structure is read-only
-    ncolors*: int
-    colors*: PColorArray
-
-  PPixelFormat* = ptr PixelFormat
-  PixelFormat*{.final.} = object  # The structure passed to the low level blit functions
-    palette*: PPalette
-    bitsPerPixel*: byte
-    bytesPerPixel*: byte
-    rloss*: byte
-    gloss*: byte
-    bloss*: byte
-    aloss*: byte
-    rshift*: byte
-    gshift*: byte
-    bshift*: byte
-    ashift*: byte
-    rMask*: int32
-    gMask*: int32
-    bMask*: int32
-    aMask*: int32
-    colorkey*: int32         # RGB color key information
-    alpha*: byte             # Alpha value information (per-surface alpha)
-  
-  PBlitInfo* = ptr BlitInfo
-  BlitInfo*{.final.} = object  # typedef for private surface blitting functions
-    sPixels*: ptr byte
-    sWidth*: int
-    sHeight*: int
-    sSkip*: int
-    dPixels*: ptr byte
-    dWidth*: int
-    dHeight*: int
-    dSkip*: int
-    auxData*: pointer
-    src*: PPixelFormat
-    table*: ptr byte
-    dst*: PPixelFormat
-
-  PSurface* = ptr Surface
-  Blit* = proc (src: PSurface, srcrect: PRect, 
-                 dst: PSurface, dstrect: PRect): int{.cdecl.}
-  Surface*{.final.} = object  # Useful for determining the video hardware capabilities
-    flags*: int32            # Read-only
-    format*: PPixelFormat     # Read-only
-    w*, h*: cint              # Read-only
-    pitch*: uint16            # Read-only
-    pixels*: pointer          # Read-write
-    offset*: cint             # Private
-    hwdata*: pointer          #TPrivate_hwdata;  Hardware-specific surface info
-                              # clipping information:
-    clipRect*: Rect           # Read-only
-    unused1*: int32           # for binary compatibility
-                              # Allow recursive locks
-    locked*: int32            # Private
-                              # info for fast blit mapping to other surfaces
-    blitmap*: pointer         # PSDL_BlitMap; //   Private
-                              # format version, bumped at every change to invalidate blit maps
-    formatVersion*: cint      # Private
-    refcount*: cint
-
-  PVideoInfo* = ptr VideoInfo
-  VideoInfo*{.final.} = object  # The YUV hardware video overlay
-    hwAvailable*: byte 
-    blitHw*: byte 
-    unusedBits3*: byte       # Unused at this point
-    videoMem*: int32        # The total amount of video memory (in K)
-    vfmt*: PPixelFormat       # Value: The format of the video surface
-    currentW*: int32        # Value: The current video mode width
-    currentH*: int32        # Value: The current video mode height
-  
-  POverlay* = ptr Overlay
-  Overlay*{.final.} = object  # Public enumeration for setting the OpenGL window attributes.
-    format*: int32           # Overlay format
-    w*, h*: int               # Width and height of overlay
-    planes*: int              # Number of planes in the overlay. Usually either 1 or 3
-    pitches*: PUInt16         # An array of pitches, one for each plane. Pitch is the length of a row in bytes.
-    pixels*: ptr ptr byte # An array of pointers to the data of each plane. The overlay should be locked before these pointers are used.
-    hwOverlay*: int32    # This will be set to 1 if the overlay is hardware accelerated.
-  
-  GLAttr* = enum 
-    GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE,
-    GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
-    GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO,
-    GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL,
-    GL_SWAP_CONTROL
-  PCursor* = ptr Cursor
-  Cursor*{.final.} = object  # SDL_mutex.h types
-    area*: Rect               # The area of the mouse cursor
-    hotX*, hot_y*: int16    # The "tip" of the cursor
-    data*: ptr byte             # B/W cursor data
-    mask*: ptr byte             # B/W cursor mask
-    save*: array[1..2, ptr byte] # Place to save cursor area
-    wmCursor*: pointer       # Window-manager cursor
-{.deprecated: [TRect: Rect, TSurface: Surface, TEvent: Event, TColor: Color,
-              TEventFilter: EventFilter, TColorArray: ColorArray,
-              # TSysWMEvent: SysWMEvent, # Naming conflict when we drop the `T`
-              TExposeEvent: ExposeEvent,
-              TQuitEvent: QuitEvent, TPalette: Palette, TPixelFormat: PixelFormat,
-              TBlitInfo: BlitInfo, TBlit: Blit, TVideoInfo: VideoInfo,
-              TOverlay: Overlay, TGLAttr: GLAttr, TCursor: Cursor].}
-
-type 
-  PMutex* = ptr Mutex
-  Mutex*{.final.} = object 
-  Psemaphore* = ptr Semaphore
-  Semaphore*{.final.} = object 
-  PSem* = ptr Sem
-  Sem* = Semaphore
-  PCond* = ptr Cond
-  Cond*{.final.} = object    # SDL_thread.h types
-{.deprecated: [TCond: Cond, TSem: Sem, TMutex: Mutex, Tsemaphore: Semaphore].}
-
-when defined(WINDOWS):
-  type 
-    SYS_ThreadHandle* = Handle
-  {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].}
-when defined(Unix):
-  type 
-    SYS_ThreadHandle* = pointer
-  {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].}
-type                          # This is the system-independent thread info structure
-  PThread* = ptr Thread
-  Thread*{.final.} = object   # Helper Types
-                              # Keyboard  State Array ( See demos for how to use )
-    threadid*: int32
-    handle*: SYS_ThreadHandle
-    status*: int
-    errbuf*: Error
-    data*: pointer
-
-  PKeyStateArr* = ptr KeyStateArr
-  KeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas
-  PInteger* = ptr int
-  PByte* = ptr int8
-  PWord* = ptr int16
-  PLongWord* = ptr int32      # General arrays
-  PByteArray* = ptr ByteArray
-  ByteArray* = array[0..32767, int8]
-  PWordArray* = ptr WordArray
-  WordArray* = array[0..16383, int16] # Generic procedure pointer
-{.deprecated: [TKeyStateArr: KeyStateArr, TByteArray: ByteArray, TThread: Thread,
-              TWordArray: WordArray].}
-
-type EventSeq = set[EventKind]
-{.deprecated: [TEventSeq: EventSeq].}
-
-template evconv(procName: expr, ptrName: typedesc, assertions: EventSeq): stmt {.immediate.} =
-  proc `procName`*(event: PEvent): ptrName =
-    assert(contains(assertions, event.kind))
-    result = cast[ptrName](event)
-
-evconv(evActive, PActiveEvent, {ACTIVEEVENT})
-evconv(evKeyboard, PKeyboardEvent, {KEYDOWN, KEYUP})
-evconv(evMouseMotion, PMouseMotionEvent, {MOUSEMOTION})
-evconv(evMouseButton, PMouseButtonEvent, {MOUSEBUTTONDOWN, MOUSEBUTTONUP})
-evconv(evJoyAxis, PJoyAxisEvent,{JOYAXISMOTION})
-evconv(evJoyBall, PJoyBallEvent, {JOYBALLMOTION})
-evconv(evJoyHat, PJoyHatEvent, {JOYHATMOTION})
-evconv(evJoyButton, PJoyButtonEvent, {JOYBUTTONDOWN, JOYBUTTONUP})
-evconv(evResize, PResizeEvent, {VIDEORESIZE})
-evconv(evExpose, PExposeEvent, {VIDEOEXPOSE})
-evconv(evQuit, PQuitEvent, {QUITEV})
-evconv(evUser, PUserEvent, {USEREVENT})
-evconv(evSysWM, PSysWMEvent, {SYSWMEVENT})
-
-#------------------------------------------------------------------------------
-# initialization
-#------------------------------------------------------------------------------
-# This function loads the SDL dynamically linked library and initializes
-#  the subsystems specified by 'flags' (and those satisfying dependencies)
-#  Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
-#  signal handlers for some commonly ignored fatal signals (like SIGSEGV)
-
-proc init*(flags: int32): int{.cdecl, importc: "SDL_Init", dynlib: LibName.}
-  # This function initializes specific SDL subsystems
-proc initSubSystem*(flags: int32): int{.cdecl, importc: "SDL_InitSubSystem", 
-    dynlib: LibName.}
-  # This function cleans up specific SDL subsystems
-proc quitSubSystem*(flags: int32){.cdecl, importc: "SDL_QuitSubSystem", 
-                                    dynlib: LibName.}
-  # This function returns mask of the specified subsystems which have
-  #  been initialized.
-  #  If 'flags' is 0, it returns a mask of all initialized subsystems.
-proc wasInit*(flags: int32): int32{.cdecl, importc: "SDL_WasInit", 
-                                      dynlib: LibName.}
-  # This function cleans up all initialized subsystems and unloads the
-  #  dynamically linked library.  You should call it upon all exit conditions.
-proc quit*(){.cdecl, importc: "SDL_Quit", dynlib: LibName.}
-when defined(WINDOWS): 
-  # This should be called from your WinMain() function, if any
-  proc registerApp*(name: cstring, style: int32, hInst: pointer): int{.cdecl, 
-      importc: "SDL_RegisterApp", dynlib: LibName.}
-proc tableSize*(table: cstring): int
-  #------------------------------------------------------------------------------
-  # error-handling
-  #------------------------------------------------------------------------------
-  # Public functions
-proc getError*(): cstring{.cdecl, importc: "SDL_GetError", dynlib: LibName.}
-proc setError*(fmt: cstring){.cdecl, importc: "SDL_SetError", dynlib: LibName.}
-proc clearError*(){.cdecl, importc: "SDL_ClearError", dynlib: LibName.}
-when not (defined(WINDOWS)):
-  proc error*(Code: ErrorCode){.cdecl, importc: "SDL_Error", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # io handling
-  #------------------------------------------------------------------------------
-  # Functions to create SDL_RWops structures from various data sources
-proc rwFromFile*(filename, mode: cstring): PRWops{.cdecl, 
-    importc: "SDL_RWFromFile", dynlib: LibName.}
-proc freeRW*(area: PRWops){.cdecl, importc: "SDL_FreeRW", dynlib: LibName.}
-  #fp is FILE *fp ???
-proc rwFromFP*(fp: pointer, autoclose: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromFP", dynlib: LibName.}
-proc rwFromMem*(mem: pointer, size: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromMem", dynlib: LibName.}
-proc rwFromConstMem*(mem: pointer, size: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromConstMem", dynlib: LibName.}
-proc allocRW*(): PRWops{.cdecl, importc: "SDL_AllocRW", dynlib: LibName.}
-proc rwSeek*(context: PRWops, offset: int, whence: int): int
-proc rwTell*(context: PRWops): int
-proc rwRead*(context: PRWops, theptr: pointer, size: int, n: int): int
-proc rwWrite*(context: PRWops, theptr: pointer, size: int, n: int): int
-proc rwClose*(context: PRWops): int
-  #------------------------------------------------------------------------------
-  # time-handling
-  #------------------------------------------------------------------------------
-  # Get the number of milliseconds since the SDL library initialization.
-  # Note that this value wraps if the program runs for more than ~49 days.
-proc getTicks*(): int32{.cdecl, importc: "SDL_GetTicks", dynlib: LibName.}
-  # Wait a specified number of milliseconds before returning
-proc delay*(msec: int32){.cdecl, importc: "SDL_Delay", dynlib: LibName.}
-  # Add a new timer to the pool of timers already running.
-  # Returns a timer ID, or NULL when an error occurs.
-proc addTimer*(interval: int32, callback: NewTimerCallback, param: pointer): PTimerID{.
-    cdecl, importc: "SDL_AddTimer", dynlib: LibName.}
-  # Remove one of the multiple timers knowing its ID.
-  # Returns a boolean value indicating success.
-proc removeTimer*(t: PTimerID): Bool{.cdecl, importc: "SDL_RemoveTimer", 
-                                       dynlib: LibName.}
-proc setTimer*(interval: int32, callback: TimerCallback): int{.cdecl, 
-    importc: "SDL_SetTimer", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # audio-routines
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the audio driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-proc audioInit*(driverName: cstring): int{.cdecl, importc: "SDL_AudioInit", 
-    dynlib: LibName.}
-proc audioQuit*(){.cdecl, importc: "SDL_AudioQuit", dynlib: LibName.}
-  # This function fills the given character buffer with the name of the
-  #  current audio driver, and returns a pointer to it if the audio driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc audioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, 
-    importc: "SDL_AudioDriverName", dynlib: LibName.}
-  # This function opens the audio device with the desired parameters, and
-  #  returns 0 if successful, placing the actual hardware parameters in the
-  #  structure pointed to by 'obtained'.  If 'obtained' is NULL, the audio
-  #  data passed to the callback function will be guaranteed to be in the
-  #  requested format, and will be automatically converted to the hardware
-  #  audio format if necessary.  This function returns -1 if it failed
-  #  to open the audio device, or couldn't set up the audio thread.
-  #
-  #  When filling in the desired audio spec structure,
-  #   'desired->freq' should be the desired audio frequency in samples-per-second.
-  #   'desired->format' should be the desired audio format.
-  #   'desired->samples' is the desired size of the audio buffer, in samples.
-  #      This number should be a power of two, and may be adjusted by the audio
-  #      driver to a value more suitable for the hardware.  Good values seem to
-  #      range between 512 and 8096 inclusive, depending on the application and
-  #      CPU speed.  Smaller values yield faster response time, but can lead
-  #      to underflow if the application is doing heavy processing and cannot
-  #      fill the audio buffer in time.  A stereo sample consists of both right
-  #      and left channels in LR ordering.
-  #      Note that the number of samples is directly related to time by the
-  #      following formula:  ms = (samples*1000)/freq
-  #   'desired->size' is the size in bytes of the audio buffer, and is
-  #      calculated by SDL_OpenAudio().
-  #   'desired->silence' is the value used to set the buffer to silence,
-  #      and is calculated by SDL_OpenAudio().
-  #   'desired->callback' should be set to a function that will be called
-  #      when the audio device is ready for more data.  It is passed a pointer
-  #      to the audio buffer, and the length in bytes of the audio buffer.
-  #      This function usually runs in a separate thread, and so you should
-  #      protect data structures that it accesses by calling SDL_LockAudio()
-  #      and SDL_UnlockAudio() in your code.
-  #   'desired->userdata' is passed as the first parameter to your callback
-  #      function.
-  #
-  #  The audio device starts out playing silence when it's opened, and should
-  #  be enabled for playing by calling SDL_PauseAudio(0) when you are ready
-  #  for your audio callback function to be called.  Since the audio driver
-  #  may modify the requested size of the audio buffer, you should allocate
-  #  any local mixing buffers after you open the audio device.
-proc openAudio*(desired, obtained: PAudioSpec): int{.cdecl, 
-    importc: "SDL_OpenAudio", dynlib: LibName.}
-  # Get the current audio state:
-proc getAudioStatus*(): Audiostatus{.cdecl, importc: "SDL_GetAudioStatus", 
-                                      dynlib: LibName.}
-  # This function pauses and unpauses the audio callback processing.
-  #  It should be called with a parameter of 0 after opening the audio
-  #  device to start playing sound.  This is so you can safely initialize
-  #  data for your callback function after opening the audio device.
-  #  Silence will be written to the audio device during the pause.
-proc pauseAudio*(pauseOn: int){.cdecl, importc: "SDL_PauseAudio", 
-                                 dynlib: LibName.}
-  # This function loads a WAVE from the data source, automatically freeing
-  #  that source if 'freesrc' is non-zero.  For example, to load a WAVE file,
-  #  you could do:
-  #  SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
-  #
-  #  If this function succeeds, it returns the given SDL_AudioSpec,
-  #  filled with the audio data format of the wave data, and sets
-  #  'audio_buf' to a malloc()'d buffer containing the audio data,
-  #  and sets 'audio_len' to the length of that audio buffer, in bytes.
-  #  You need to free the audio buffer with SDL_FreeWAV() when you are
-  #  done with it.
-  #
-  #  This function returns NULL and sets the SDL error message if the
-  #  wave file cannot be opened, uses an unknown data format, or is
-  #  corrupt.  Currently raw and MS-ADPCM WAVE files are supported.
-proc loadWAV_RW*(src: PRWops, freesrc: int, spec: PAudioSpec, audioBuf: ptr byte, 
-                 audiolen: PUInt32): PAudioSpec{.cdecl, 
-    importc: "SDL_LoadWAV_RW", dynlib: LibName.}
-  # Compatibility convenience function -- loads a WAV from a file
-proc loadWAV*(filename: cstring, spec: PAudioSpec, audioBuf: ptr byte, 
-              audiolen: PUInt32): PAudioSpec
-  # This function frees data previously allocated with SDL_LoadWAV_RW()
-proc freeWAV*(audioBuf: ptr byte){.cdecl, importc: "SDL_FreeWAV", dynlib: LibName.}
-  # This function takes a source format and rate and a destination format
-  #  and rate, and initializes the 'cvt' structure with information needed
-  #  by SDL_ConvertAudio() to convert a buffer of audio data from one format
-  #  to the other.
-  #  This function returns 0, or -1 if there was an error.
-proc buildAudioCVT*(cvt: PAudioCVT, srcFormat: uint16, srcChannels: byte, 
-                    srcRate: int, dstFormat: uint16, dstChannels: byte, 
-                    dstRate: int): int{.cdecl, importc: "SDL_BuildAudioCVT", 
-    dynlib: LibName.}
-  # Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
-  #  created an audio buffer cvt->buf, and filled it with cvt->len bytes of
-  #  audio data in the source format, this function will convert it in-place
-  #  to the desired format.
-  #  The data conversion may expand the size of the audio data, so the buffer
-  #  cvt->buf should be allocated after the cvt structure is initialized by
-  #  SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
-proc convertAudio*(cvt: PAudioCVT): int{.cdecl, importc: "SDL_ConvertAudio", 
-    dynlib: LibName.}
-  # This takes two audio buffers of the playing audio format and mixes
-  #  them, performing addition, volume adjustment, and overflow clipping.
-  #  The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
-  #  for full audio volume.  Note this does not change hardware volume.
-  #  This is provided for convenience -- you can mix your own audio data.
-proc mixAudio*(dst, src: ptr byte, length: int32, volume: int){.cdecl, 
-    importc: "SDL_MixAudio", dynlib: LibName.}
-  # The lock manipulated by these functions protects the callback function.
-  #  During a LockAudio/UnlockAudio pair, you can be guaranteed that the
-  #  callback function is not running.  Do not call these from the callback
-  #  function or you will cause deadlock.
-proc lockAudio*(){.cdecl, importc: "SDL_LockAudio", dynlib: LibName.}
-proc unlockAudio*(){.cdecl, importc: "SDL_UnlockAudio", dynlib: LibName.}
-  # This function shuts down audio processing and closes the audio device.
-proc closeAudio*(){.cdecl, importc: "SDL_CloseAudio", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # CD-routines
-  #------------------------------------------------------------------------------
-  # Returns the number of CD-ROM drives on the system, or -1 if
-  #  SDL_Init() has not been called with the SDL_INIT_CDROM flag.
-proc cdNumDrives*(): int{.cdecl, importc: "SDL_CDNumDrives", dynlib: LibName.}
-  # Returns a human-readable, system-dependent identifier for the CD-ROM.
-  #   Example:
-  #   "/dev/cdrom"
-  #   "E:"
-  #   "/dev/disk/ide/1/master"
-proc cdName*(drive: int): cstring{.cdecl, importc: "SDL_CDName", dynlib: LibName.}
-  # Opens a CD-ROM drive for access.  It returns a drive handle on success,
-  #  or NULL if the drive was invalid or busy.  This newly opened CD-ROM
-  #  becomes the default CD used when other CD functions are passed a NULL
-  #  CD-ROM handle.
-  #  Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
-proc cdOpen*(drive: int): PCD{.cdecl, importc: "SDL_CDOpen", dynlib: LibName.}
-  # This function returns the current status of the given drive.
-  #  If the drive has a CD in it, the table of contents of the CD and current
-  #  play position of the CD will be stored in the SDL_CD structure.
-proc cdStatus*(cdrom: PCD): CDStatus{.cdecl, importc: "SDL_CDStatus", 
-                                       dynlib: LibName.}
-  #  Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
-  #   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play
-  #   until the end of the CD.  This function will skip data tracks.
-  #   This function should only be called after calling SDL_CDStatus() to
-  #   get track information about the CD.
-  #
-  #   For example:
-  #   // Play entire CD:
-  #  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
-  #   // Play last track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #   begin
-  #    SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
-  #   end;
-  #
-  #   // Play first and second track and 10 seconds of third track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
-  #
-  #   This function returns 0, or -1 if there was an error.
-proc cdPlayTracks*(cdrom: PCD, startTrack: int, startFrame: int, ntracks: int, 
-                   nframes: int): int{.cdecl, importc: "SDL_CDPlayTracks", 
-                                       dynlib: LibName.}
-  #  Play the given CD starting at 'start' frame for 'length' frames.
-  #   It returns 0, or -1 if there was an error.
-proc cdPlay*(cdrom: PCD, start: int, len: int): int{.cdecl, 
-    importc: "SDL_CDPlay", dynlib: LibName.}
-  # Pause play -- returns 0, or -1 on error
-proc cdPause*(cdrom: PCD): int{.cdecl, importc: "SDL_CDPause", dynlib: LibName.}
-  # Resume play -- returns 0, or -1 on error
-proc cdResume*(cdrom: PCD): int{.cdecl, importc: "SDL_CDResume", dynlib: LibName.}
-  # Stop play -- returns 0, or -1 on error
-proc cdStop*(cdrom: PCD): int{.cdecl, importc: "SDL_CDStop", dynlib: LibName.}
-  # Eject CD-ROM -- returns 0, or -1 on error
-proc cdEject*(cdrom: PCD): int{.cdecl, importc: "SDL_CDEject", dynlib: LibName.}
-  # Closes the handle for the CD-ROM drive
-proc cdClose*(cdrom: PCD){.cdecl, importc: "SDL_CDClose", dynlib: LibName.}
-  # Given a status, returns true if there's a disk in the drive
-proc cdInDrive*(status: CDStatus): bool
-
-proc numJoysticks*(): int{.cdecl, importc: "SDL_NumJoysticks", dynlib: LibName.}
-  # Get the implementation dependent name of a joystick.
-  #  This can be called before any joysticks are opened.
-  #  If no name can be found, this function returns NULL.
-proc joystickName*(index: int): cstring{.cdecl, importc: "SDL_JoystickName", 
-    dynlib: LibName.}
-  # Open a joystick for use - the index passed as an argument refers to
-  #  the N'th joystick on the system.  This index is the value which will
-  #  identify this joystick in future joystick events.
-  #
-  #  This function returns a joystick identifier, or NULL if an error occurred.
-proc joystickOpen*(index: int): PJoystick{.cdecl, importc: "SDL_JoystickOpen", 
-    dynlib: LibName.}
-  # Returns 1 if the joystick has been opened, or 0 if it has not.
-proc joystickOpened*(index: int): int{.cdecl, importc: "SDL_JoystickOpened", 
-                                       dynlib: LibName.}
-  # Get the device index of an opened joystick.
-proc joystickIndex*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickIndex", dynlib: LibName.}
-  # Get the number of general axis controls on a joystick
-proc joystickNumAxes*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumAxes", dynlib: LibName.}
-  # Get the number of trackballs on a joystick
-  #  Joystick trackballs have only relative motion events associated
-  #  with them and their state cannot be polled.
-proc joystickNumBalls*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumBalls", dynlib: LibName.}
-  # Get the number of POV hats on a joystick
-proc joystickNumHats*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumHats", dynlib: LibName.}
-  # Get the number of buttons on a joystick
-proc joystickNumButtons*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumButtons", dynlib: LibName.}
-  # Update the current state of the open joysticks.
-  #  This is called automatically by the event loop if any joystick
-  #  events are enabled.
-proc joystickUpdate*(){.cdecl, importc: "SDL_JoystickUpdate", dynlib: LibName.}
-  # Enable/disable joystick event polling.
-  #  If joystick events are disabled, you must call SDL_JoystickUpdate()
-  #  yourself and check the state of the joystick when you want joystick
-  #  information.
-  #  The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
-proc joystickEventState*(state: int): int{.cdecl, 
-    importc: "SDL_JoystickEventState", dynlib: LibName.}
-  # Get the current state of an axis control on a joystick
-  #  The state is a value ranging from -32768 to 32767.
-  #  The axis indices start at index 0.
-proc joystickGetAxis*(joystick: PJoystick, axis: int): int16{.cdecl, 
-    importc: "SDL_JoystickGetAxis", dynlib: LibName.}
-  # The hat indices start at index 0.
-proc joystickGetHat*(joystick: PJoystick, hat: int): byte{.cdecl, 
-    importc: "SDL_JoystickGetHat", dynlib: LibName.}
-  # Get the ball axis change since the last poll
-  #  This returns 0, or -1 if you passed it invalid parameters.
-  #  The ball indices start at index 0.
-proc joystickGetBall*(joystick: PJoystick, ball: int, dx: var int, dy: var int): int{.
-    cdecl, importc: "SDL_JoystickGetBall", dynlib: LibName.}
-  # Get the current state of a button on a joystick
-  #  The button indices start at index 0.
-proc joystickGetButton*(joystick: PJoystick, button: int): byte{.cdecl, 
-    importc: "SDL_JoystickGetButton", dynlib: LibName.}
-  # Close a joystick previously opened with SDL_JoystickOpen()
-proc joystickClose*(joystick: PJoystick){.cdecl, importc: "SDL_JoystickClose", 
-    dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # event-handling
-  #------------------------------------------------------------------------------
-  # Pumps the event loop, gathering events from the input devices.
-  #  This function updates the event queue and internal input device state.
-  #  This should only be run in the thread that sets the video mode.
-proc pumpEvents*(){.cdecl, importc: "SDL_PumpEvents", dynlib: LibName.}
-  # Checks the event queue for messages and optionally returns them.
-  #  If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-  #  the back of the event queue.
-  #  If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will not
-  #  be removed from the queue.
-  #  If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will be
-  #  removed from the queue.
-  #  This function returns the number of events actually stored, or -1
-  #  if there was an error.  This function is thread-safe.
-proc peepEvents*(events: PEvent, numevents: int, action: EventAction, 
-                 mask: int32): int{.cdecl, importc: "SDL_PeepEvents", 
-                                     dynlib: LibName.}
-  # Polls for currently pending events, and returns 1 if there are any pending
-  #   events, or 0 if there are none available.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc pollEvent*(event: PEvent): int{.cdecl, importc: "SDL_PollEvent", 
-                                     dynlib: LibName.}
-  #  Waits indefinitely for the next available event, returning 1, or 0 if there
-  #   was an error while waiting for events.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc waitEvent*(event: PEvent): int{.cdecl, importc: "SDL_WaitEvent", 
-                                     dynlib: LibName.}
-proc pushEvent*(event: PEvent): int{.cdecl, importc: "SDL_PushEvent", 
-                                     dynlib: LibName.}
-  # If the filter returns 1, then the event will be added to the internal queue.
-  #  If it returns 0, then the event will be dropped from the queue, but the
-  #  internal state will still be updated.  This allows selective filtering of
-  #  dynamically arriving events.
-  #
-  #  WARNING:  Be very careful of what you do in the event filter function, as
-  #            it may run in a different thread!
-  #
-  #  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
-  #  event filter is only called when the window manager desires to close the
-  #  application window.  If the event filter returns 1, then the window will
-  #  be closed, otherwise the window will remain open if possible.
-  #  If the quit event is generated by an interrupt signal, it will bypass the
-  #  internal queue and be delivered to the application at the next event poll.
-proc setEventFilter*(filter: EventFilter){.cdecl, 
-    importc: "SDL_SetEventFilter", dynlib: LibName.}
-  # Return the current event filter - can be used to "chain" filters.
-  #  If there is no event filter set, this function returns NULL.
-proc getEventFilter*(): EventFilter{.cdecl, importc: "SDL_GetEventFilter", 
-                                      dynlib: LibName.}
-  # This function allows you to set the state of processing certain events.
-  #  If 'state' is set to SDL_IGNORE, that event will be automatically dropped
-  #  from the event queue and will not event be filtered.
-  #  If 'state' is set to SDL_ENABLE, that event will be processed normally.
-  #  If 'state' is set to SDL_QUERY, SDL_EventState() will return the
-  #  current processing state of the specified event.
-proc eventState*(theType: byte, state: int): byte{.cdecl, 
-    importc: "SDL_EventState", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Version Routines
-  #------------------------------------------------------------------------------
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library.
-proc version*(x: var Version)
-  # This macro turns the version numbers into a numeric value:
-  #   (1,2,3) -> (1203)
-  #   This assumes that there will never be more than 100 patchlevels
-proc versionnum*(x, y, z: int): int
-  # This is the version number macro for the current SDL version
-proc compiledversion*(): int
-  # This macro will evaluate to true if compiled with SDL at least X.Y.Z
-proc versionAtleast*(x, y, z: int): bool
-  # This function gets the version of the dynamically linked SDL library.
-  #  it should NOT be used to fill a version structure, instead you should
-  #  use the SDL_Version() macro.
-proc linkedVersion*(): PVersion{.cdecl, importc: "SDL_Linked_Version", 
-                                  dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # video
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the video driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-  #
-  #  SDL_VideoInit() initializes the video subsystem -- sets up a connection
-  #  to the window manager, etc, and determines the current video mode and
-  #  pixel format, but does not initialize a window or graphics mode.
-  #  Note that event handling is activated by this routine.
-  #
-  #  If you use both sound and video in your application, you need to call
-  #  SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
-  #  you won't be able to set full-screen display modes.
-proc videoInit*(driverName: cstring, flags: int32): int{.cdecl, 
-    importc: "SDL_VideoInit", dynlib: LibName.}
-proc videoQuit*(){.cdecl, importc: "SDL_VideoQuit", dynlib: LibName.}
-  # This function fills the given character buffer with the name of the
-  #  video driver, and returns a pointer to it if the video driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc videoDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, 
-    importc: "SDL_VideoDriverName", dynlib: LibName.}
-  # This function returns a pointer to the current display surface.
-  #  If SDL is doing format conversion on the display surface, this
-  #  function returns the publicly visible surface, not the real video
-  #  surface.
-proc getVideoSurface*(): PSurface{.cdecl, importc: "SDL_GetVideoSurface", 
-                                   dynlib: LibName.}
-  # This function returns a read-only pointer to information about the
-  #  video hardware.  If this is called before SDL_SetVideoMode(), the 'vfmt'
-  #  member of the returned structure will contain the pixel format of the
-  #  "best" video mode.
-proc getVideoInfo*(): PVideoInfo{.cdecl, importc: "SDL_GetVideoInfo", 
-                                  dynlib: LibName.}
-  # Check to see if a particular video mode is supported.
-  #  It returns 0 if the requested mode is not supported under any bit depth,
-  #  or returns the bits-per-pixel of the closest available mode with the
-  #  given width and height.  If this bits-per-pixel is different from the
-  #  one used when setting the video mode, SDL_SetVideoMode() will succeed,
-  #  but will emulate the requested bits-per-pixel with a shadow surface.
-  #
-  #  The arguments to SDL_VideoModeOK() are the same ones you would pass to
-  #  SDL_SetVideoMode()
-proc videoModeOK*(width, height, bpp: int, flags: int32): int{.cdecl, 
-    importc: "SDL_VideoModeOK", importc: "SDL_VideoModeOK", dynlib: LibName.}
-  # Return a pointer to an array of available screen dimensions for the
-  #  given format and video flags, sorted largest to smallest.  Returns
-  #  NULL if there are no dimensions available for a particular format,
-  #  or (SDL_Rect **)-1 if any dimension is okay for the given format.
-  #
-  #  if 'format' is NULL, the mode list will be for the format given
-  #  by SDL_GetVideoInfo( ) - > vfmt
-proc listModes*(format: PPixelFormat, flags: int32): PPSDL_Rect{.cdecl, 
-    importc: "SDL_ListModes", dynlib: LibName.}
-  # Set up a video mode with the specified width, height and bits-per-pixel.
-  #
-  #  If 'bpp' is 0, it is treated as the current display bits per pixel.
-  #
-  #  If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
-  #  requested bits-per-pixel, but will return whatever video pixel format is
-  #  available.  The default is to emulate the requested pixel format if it
-  #  is not natively available.
-  #
-  #  If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
-  #  video memory, if possible, and you may have to call SDL_LockSurface()
-  #  in order to access the raw framebuffer.  Otherwise, the video surface
-  #  will be created in system memory.
-  #
-  #  If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
-  #  updates asynchronously, but you must always lock before accessing pixels.
-  #  SDL will wait for updates to complete before returning from the lock.
-  #
-  #  If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
-  #  that the colors set by SDL_SetColors() will be the colors you get.
-  #  Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
-  #  of the colors exactly the way they are requested, and you should look
-  #  at the video surface structure to determine the actual palette.
-  #  If SDL cannot guarantee that the colors you request can be set,
-  #  i.e. if the colormap is shared, then the video surface may be created
-  #  under emulation in system memory, overriding the SDL_HWSURFACE flag.
-  #
-  #  If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
-  #  a fullscreen video mode.  The default is to create a windowed mode
-  #  if the current graphics system has a window manager.
-  #  If the SDL library is able to set a fullscreen video mode, this flag
-  #  will be set in the surface that is returned.
-  #
-  #  If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
-  #  two surfaces in video memory and swap between them when you call
-  #  SDL_Flip().  This is usually slower than the normal single-buffering
-  #  scheme, but prevents "tearing" artifacts caused by modifying video
-  #  memory while the monitor is refreshing.  It should only be used by
-  #  applications that redraw the entire screen on every update.
-  #
-  #  This function returns the video framebuffer surface, or NULL if it fails.
-proc setVideoMode*(width, height, bpp: int, flags: uint32): PSurface{.cdecl, 
-    importc: "SDL_SetVideoMode", dynlib: LibName.}
-  # Makes sure the given list of rectangles is updated on the given screen.
-  #  If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
-  #  screen.
-  #  These functions should not be called while 'screen' is locked.
-proc updateRects*(screen: PSurface, numrects: int, rects: PRect){.cdecl, 
-    importc: "SDL_UpdateRects", dynlib: LibName.}
-proc updateRect*(screen: PSurface, x, y: int32, w, h: int32){.cdecl, 
-    importc: "SDL_UpdateRect", dynlib: LibName.}
-  # On hardware that supports double-buffering, this function sets up a flip
-  #  and returns.  The hardware will wait for vertical retrace, and then swap
-  #  video buffers before the next video surface blit or lock will return.
-  #  On hardware that doesn not support double-buffering, this is equivalent
-  #  to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
-  #  The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
-  #  setting the video mode for this function to perform hardware flipping.
-  #  This function returns 0 if successful, or -1 if there was an error.
-proc flip*(screen: PSurface): int{.cdecl, importc: "SDL_Flip", dynlib: LibName.}
-  # Set the gamma correction for each of the color channels.
-  #  The gamma values range (approximately) between 0.1 and 10.0
-  #
-  #  If this function isn't supported directly by the hardware, it will
-  #  be emulated using gamma ramps, if available.  If successful, this
-  #  function returns 0, otherwise it returns -1.
-proc setGamma*(redgamma: float32, greengamma: float32, bluegamma: float32): int{.
-    cdecl, importc: "SDL_SetGamma", dynlib: LibName.}
-  # Set the gamma translation table for the red, green, and blue channels
-  #  of the video hardware.  Each table is an array of 256 16-bit quantities,
-  #  representing a mapping between the input and output for that channel.
-  #  The input is the index into the array, and the output is the 16-bit
-  #  gamma value at that index, scaled to the output color precision.
-  #
-  #  You may pass NULL for any of the channels to leave it unchanged.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc setGammaRamp*(redtable: PUInt16, greentable: PUInt16, bluetable: PUInt16): int{.
-    cdecl, importc: "SDL_SetGammaRamp", dynlib: LibName.}
-  # Retrieve the current values of the gamma translation tables.
-  #
-  #  You must pass in valid pointers to arrays of 256 16-bit quantities.
-  #  Any of the pointers may be NULL to ignore that channel.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc getGammaRamp*(redtable: PUInt16, greentable: PUInt16, bluetable: PUInt16): int{.
-    cdecl, importc: "SDL_GetGammaRamp", dynlib: LibName.}
-  # Sets a portion of the colormap for the given 8-bit surface.  If 'surface'
-  #  is not a palettized surface, this function does nothing, returning 0.
-  #  If all of the colors were set as passed to SDL_SetColors(), it will
-  #  return 1.  If not all the color entries were set exactly as given,
-  #  it will return 0, and you should look at the surface palette to
-  #  determine the actual color palette.
-  #
-  #  When 'surface' is the surface associated with the current display, the
-  #  display colormap will be updated with the requested colors.  If
-  #  SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
-  #  will always return 1, and the palette is guaranteed to be set the way
-  #  you desire, even if the window colormap has to be warped or run under
-  #  emulation.
-proc setColors*(surface: PSurface, colors: PColor, firstcolor: int, ncolors: int): int{.
-    cdecl, importc: "SDL_SetColors", dynlib: LibName.}
-  # Sets a portion of the colormap for a given 8-bit surface.
-  #  'flags' is one or both of:
-  #  SDL_LOGPAL  -- set logical palette, which controls how blits are mapped
-  #                 to/from the surface,
-  #  SDL_PHYSPAL -- set physical palette, which controls how pixels look on
-  #                 the screen
-  #  Only screens have physical palettes. Separate change of physical/logical
-  #  palettes is only possible if the screen has SDL_HWPALETTE set.
-  #
-  #  The return value is 1 if all colours could be set as requested, and 0
-  #  otherwise.
-  #
-  #  SDL_SetColors() is equivalent to calling this function with
-  #  flags = (SDL_LOGPAL or SDL_PHYSPAL).
-proc setPalette*(surface: PSurface, flags: int, colors: PColor, firstcolor: int, 
-                 ncolors: int): int{.cdecl, importc: "SDL_SetPalette", 
-                                     dynlib: LibName.}
-  # Maps an RGB triple to an opaque pixel value for a given pixel format
-proc mapRGB*(format: PPixelFormat, r: byte, g: byte, b: byte): int32{.cdecl, 
-    importc: "SDL_MapRGB", dynlib: LibName.}
-  # Maps an RGBA quadruple to a pixel value for a given pixel format
-proc mapRGBA*(format: PPixelFormat, r: byte, g: byte, b: byte, a: byte): int32{.
-    cdecl, importc: "SDL_MapRGBA", dynlib: LibName.}
-  # Maps a pixel value into the RGB components for a given pixel format
-proc getRGB*(pixel: int32, fmt: PPixelFormat, r: ptr byte, g: ptr byte, b: ptr byte){.
-    cdecl, importc: "SDL_GetRGB", dynlib: LibName.}
-  # Maps a pixel value into the RGBA components for a given pixel format
-proc getRGBA*(pixel: int32, fmt: PPixelFormat, r: ptr byte, g: ptr byte, b: ptr byte, 
-              a: ptr byte){.cdecl, importc: "SDL_GetRGBA", dynlib: LibName.}
-  # Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
-  #  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
-  #  If the depth is greater than 8 bits, the pixel format is set using the
-  #  flags '[RGB]mask'.
-  #  If the function runs out of memory, it will return NULL.
-  #
-  #  The 'flags' tell what kind of surface to create.
-  #  SDL_SWSURFACE means that the surface should be created in system memory.
-  #  SDL_HWSURFACE means that the surface should be created in video memory,
-  #  with the same format as the display surface.  This is useful for surfaces
-  #  that will not change much, to take advantage of hardware acceleration
-  #  when being blitted to the display surface.
-  #  SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
-  #  this surface, but you must always lock it before accessing the pixels.
-  #  SDL will wait for current blits to finish before returning from the lock.
-  #  SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
-  #  If the hardware supports acceleration of colorkey blits between
-  #  two surfaces in video memory, SDL will try to place the surface in
-  #  video memory. If this isn't possible or if there is no hardware
-  #  acceleration available, the surface will be placed in system memory.
-  #  SDL_SRCALPHA means that the surface will be used for alpha blits and
-  #  if the hardware supports hardware acceleration of alpha blits between
-  #  two surfaces in video memory, to place the surface in video memory
-  #  if possible, otherwise it will be placed in system memory.
-  #  If the surface is created in video memory, blits will be _much_ faster,
-  #  but the surface format must be identical to the video surface format,
-  #  and the only way to access the pixels member of the surface is to use
-  #  the SDL_LockSurface() and SDL_UnlockSurface() calls.
-  #  If the requested surface actually resides in video memory, SDL_HWSURFACE
-  #  will be set in the flags member of the returned surface.  If for some
-  #  reason the surface could not be placed in video memory, it will not have
-  #  the SDL_HWSURFACE flag set, and will be created in system memory instead.
-proc allocSurface*(flags: int32, width, height, depth: int, 
-                   rMask, gMask, bMask, aMask: int32): PSurface
-proc createRGBSurface*(flags: int32, width, height, depth: int, 
-                       rMask, gMask, bMask, aMask: int32): PSurface{.cdecl, 
-    importc: "SDL_CreateRGBSurface", dynlib: LibName.}
-proc createRGBSurfaceFrom*(pixels: pointer, width, height, depth, pitch: int, 
-                           rMask, gMask, bMask, aMask: int32): PSurface{.cdecl, 
-    importc: "SDL_CreateRGBSurfaceFrom", dynlib: LibName.}
-proc freeSurface*(surface: PSurface){.cdecl, importc: "SDL_FreeSurface", 
-                                      dynlib: LibName.}
-proc mustLock*(surface: PSurface): bool
-  # SDL_LockSurface() sets up a surface for directly accessing the pixels.
-  #  Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
-  #  to and read from 'surface->pixels', using the pixel format stored in
-  #  'surface->format'.  Once you are done accessing the surface, you should
-  #  use SDL_UnlockSurface() to release it.
-  #
-  #  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
-  #  to 0, then you can read and write to the surface at any time, and the
-  #  pixel format of the surface will not change.  In particular, if the
-  #  SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
-  #  will not need to lock the display surface before accessing it.
-  #
-  #  No operating system or library calls should be made between lock/unlock
-  #  pairs, as critical system locks may be held during this time.
-  #
-  #  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
-proc lockSurface*(surface: PSurface): int{.cdecl, importc: "SDL_LockSurface", 
-    dynlib: LibName.}
-proc unlockSurface*(surface: PSurface){.cdecl, importc: "SDL_UnlockSurface", 
-                                        dynlib: LibName.}
-  # Load a surface from a seekable SDL data source (memory or file.)
-  #  If 'freesrc' is non-zero, the source will be closed after being read.
-  #  Returns the new surface, or NULL if there was an error.
-  #  The new surface should be freed with SDL_FreeSurface().
-proc loadBMP_RW*(src: PRWops, freesrc: int): PSurface{.cdecl, 
-    importc: "SDL_LoadBMP_RW", dynlib: LibName.}
-  # Convenience macro -- load a surface from a file
-proc loadBMP*(filename: cstring): PSurface
-  # Save a surface to a seekable SDL data source (memory or file.)
-  #  If 'freedst' is non-zero, the source will be closed after being written.
-  #  Returns 0 if successful or -1 if there was an error.
-proc saveBMP_RW*(surface: PSurface, dst: PRWops, freedst: int): int{.cdecl, 
-    importc: "SDL_SaveBMP_RW", dynlib: LibName.}
-  # Convenience macro -- save a surface to a file
-proc saveBMP*(surface: PSurface, filename: cstring): int
-  # Sets the color key (transparent pixel) in a blittable surface.
-  #  If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
-  #  'key' will be the transparent pixel in the source image of a blit.
-  #  SDL_RLEACCEL requests RLE acceleration for the surface if present,
-  #  and removes RLE acceleration if absent.
-  #  If 'flag' is 0, this function clears any current color key.
-  #  This function returns 0, or -1 if there was an error.
-proc setColorKey*(surface: PSurface, flag, key: int32): int{.cdecl, 
-    importc: "SDL_SetColorKey", dynlib: LibName.}
-  # This function sets the alpha value for the entire surface, as opposed to
-  #  using the alpha component of each pixel. This value measures the range
-  #  of transparency of the surface, 0 being completely transparent to 255
-  #  being completely opaque. An 'alpha' value of 255 causes blits to be
-  #  opaque, the source pixels copied to the destination (the default). Note
-  #  that per-surface alpha can be combined with colorkey transparency.
-  #
-  #  If 'flag' is 0, alpha blending is disabled for the surface.
-  #  If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
-  #  OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
-  #  surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
-proc setAlpha*(surface: PSurface, flag: int32, alpha: byte): int{.cdecl, 
-    importc: "SDL_SetAlpha", dynlib: LibName.}
-  # Sets the clipping rectangle for the destination surface in a blit.
-  #
-  #  If the clip rectangle is NULL, clipping will be disabled.
-  #  If the clip rectangle doesn't intersect the surface, the function will
-  #  return SDL_FALSE and blits will be completely clipped.  Otherwise the
-  #  function returns SDL_TRUE and blits to the surface will be clipped to
-  #  the intersection of the surface area and the clipping rectangle.
-  #
-  #  Note that blits are automatically clipped to the edges of the source
-  #  and destination surfaces.
-proc setClipRect*(surface: PSurface, rect: PRect){.cdecl, 
-    importc: "SDL_SetClipRect", dynlib: LibName.}
-  # Gets the clipping rectangle for the destination surface in a blit.
-  #  'rect' must be a pointer to a valid rectangle which will be filled
-  #  with the correct values.
-proc getClipRect*(surface: PSurface, rect: PRect){.cdecl, 
-    importc: "SDL_GetClipRect", dynlib: LibName.}
-  # Creates a new surface of the specified format, and then copies and maps
-  #  the given surface to it so the blit of the converted surface will be as
-  #  fast as possible.  If this function fails, it returns NULL.
-  #
-  #  The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
-  #  semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
-  #  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
-  #  surface.
-  #
-  #  This function is used internally by SDL_DisplayFormat().
-proc convertSurface*(src: PSurface, fmt: PPixelFormat, flags: int32): PSurface{.
-    cdecl, importc: "SDL_ConvertSurface", dynlib: LibName.}
-  #
-  #  This performs a fast blit from the source surface to the destination
-  #  surface.  It assumes that the source and destination rectangles are
-  #  the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
-  #  surface (src or dst) is copied.  The final blit rectangles are saved
-  #  in 'srcrect' and 'dstrect' after all clipping is performed.
-  #  If the blit is successful, it returns 0, otherwise it returns -1.
-  #
-  #  The blit function should not be called on a locked surface.
-  #
-  #  The blit semantics for surfaces with and without alpha and colorkey
-  #  are defined as follows:
-  #
-  #  RGBA->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using alpha-channel).
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value);
-  #   set destination alpha to opaque.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB, set destination alpha to opaque.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  RGBA->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source alpha channel) the RGB values;
-  #   leave destination alpha untouched. [Note: is this correct?]
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy all of RGBA to the destination.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value).
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  If either of the surfaces were in video memory, and the blit returns -2,
-  #  the video memory was lost, so it should be reloaded with artwork and
-  #  re-blitted:
-  #  while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
-  #  begin
-  #  while ( SDL_LockSurface(image) < 0 ) do
-  #   Sleep(10);
-  #  -- Write image pixels to image->pixels --
-  #  SDL_UnlockSurface(image);
-  # end;
-  #
-  #  This happens under DirectX 5.0 when the system switches away from your
-  #  fullscreen application.  The lock will also fail until you have access
-  #  to the video memory again.
-  # You should call SDL_BlitSurface() unless you know exactly how SDL
-  #   blitting works internally and how to use the other blit functions.
-proc blitSurface*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int
-  #  This is the public blit function, SDL_BlitSurface(), and it performs
-  #   rectangle validation and clipping before passing it to SDL_LowerBlit()
-proc upperBlit*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int{.
-    cdecl, importc: "SDL_UpperBlit", dynlib: LibName.}
-  # This is a semi-private blit function and it performs low-level surface
-  #  blitting only.
-proc lowerBlit*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int{.
-    cdecl, importc: "SDL_LowerBlit", dynlib: LibName.}
-  # This function performs a fast fill of the given rectangle with 'color'
-  #  The given rectangle is clipped to the destination surface clip area
-  #  and the final fill rectangle is saved in the passed in pointer.
-  #  If 'dstrect' is NULL, the whole surface will be filled with 'color'
-  #  The color should be a pixel of the format used by the surface, and
-  #  can be generated by the SDL_MapRGB() function.
-  #  This function returns 0 on success, or -1 on error.
-proc fillRect*(dst: PSurface, dstrect: PRect, color: int32): int{.cdecl, 
-    importc: "SDL_FillRect", dynlib: LibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer, suitable for fast
-  #  blitting onto the display surface.  It calls SDL_ConvertSurface()
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc displayFormat*(surface: PSurface): PSurface{.cdecl, 
-    importc: "SDL_DisplayFormat", dynlib: LibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer (if possible),
-  #  suitable for fast alpha blitting onto the display surface.
-  #  The new surface will always have an alpha channel.
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc displayFormatAlpha*(surface: PSurface): PSurface{.cdecl, 
-    importc: "SDL_DisplayFormatAlpha", dynlib: LibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  #* YUV video surface overlay functions                                       */
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  # This function creates a video output overlay
-  #  Calling the returned surface an overlay is something of a misnomer because
-  #  the contents of the display surface underneath the area where the overlay
-  #  is shown is undefined - it may be overwritten with the converted YUV data.
-proc createYUVOverlay*(width: int, height: int, format: int32, 
-                       display: PSurface): POverlay{.cdecl, 
-    importc: "SDL_CreateYUVOverlay", dynlib: LibName.}
-  # Lock an overlay for direct access, and unlock it when you are done
-proc lockYUVOverlay*(overlay: POverlay): int{.cdecl, 
-    importc: "SDL_LockYUVOverlay", dynlib: LibName.}
-proc unlockYUVOverlay*(overlay: POverlay){.cdecl, 
-    importc: "SDL_UnlockYUVOverlay", dynlib: LibName.}
-  # Blit a video overlay to the display surface.
-  #  The contents of the video surface underneath the blit destination are
-  #  not defined.
-  #  The width and height of the destination rectangle may be different from
-  #  that of the overlay, but currently only 2x scaling is supported.
-proc displayYUVOverlay*(overlay: POverlay, dstrect: PRect): int{.cdecl, 
-    importc: "SDL_DisplayYUVOverlay", dynlib: LibName.}
-  # Free a video overlay
-proc freeYUVOverlay*(overlay: POverlay){.cdecl, importc: "SDL_FreeYUVOverlay", 
-    dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # OpenGL Routines
-  #------------------------------------------------------------------------------
-  # Dynamically load a GL driver, if SDL is built with dynamic GL.
-  #
-  #  SDL links normally with the OpenGL library on your system by default,
-  #  but you can compile it to dynamically load the GL driver at runtime.
-  #  If you do this, you need to retrieve all of the GL functions used in
-  #  your program from the dynamic library using SDL_GL_GetProcAddress().
-  #
-  #  This is disabled in default builds of SDL.
-proc glLoadLibrary*(filename: cstring): int{.cdecl, 
-    importc: "SDL_GL_LoadLibrary", dynlib: LibName.}
-  # Get the address of a GL function (for extension functions)
-proc glGetProcAddress*(procname: cstring): pointer{.cdecl, 
-    importc: "SDL_GL_GetProcAddress", dynlib: LibName.}
-  # Set an attribute of the OpenGL subsystem before intialization.
-proc glSetAttribute*(attr: GLAttr, value: int): int{.cdecl, 
-    importc: "SDL_GL_SetAttribute", dynlib: LibName.}
-  # Get an attribute of the OpenGL subsystem from the windowing
-  #  interface, such as glX. This is of course different from getting
-  #  the values from SDL's internal OpenGL subsystem, which only
-  #  stores the values you request before initialization.
-  #
-  #  Developers should track the values they pass into SDL_GL_SetAttribute
-  #  themselves if they want to retrieve these values.
-proc glGetAttribute*(attr: GLAttr, value: var int): int{.cdecl, 
-    importc: "SDL_GL_GetAttribute", dynlib: LibName.}
-  # Swap the OpenGL buffers, if double-buffering is supported.
-proc glSwapBuffers*(){.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.}
-  # Internal functions that should not be called unless you have read
-  #  and understood the source code for these functions.
-proc glUpdateRects*(numrects: int, rects: PRect){.cdecl, 
-    importc: "SDL_GL_UpdateRects", dynlib: LibName.}
-proc glLock*(){.cdecl, importc: "SDL_GL_Lock", dynlib: LibName.}
-proc glUnlock*(){.cdecl, importc: "SDL_GL_Unlock", dynlib: LibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  #* These functions allow interaction with the window manager, if any.        *
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Sets/Gets the title and icon text of the display window
-proc wmGetCaption*(title: var cstring, icon: var cstring){.cdecl, 
-    importc: "SDL_WM_GetCaption", dynlib: LibName.}
-proc wmSetCaption*(title: cstring, icon: cstring){.cdecl, 
-    importc: "SDL_WM_SetCaption", dynlib: LibName.}
-  # Sets the icon for the display window.
-  #  This function must be called before the first call to SDL_SetVideoMode().
-  #  It takes an icon surface, and a mask in MSB format.
-  #  If 'mask' is NULL, the entire icon surface will be used as the icon.
-proc wmSetIcon*(icon: PSurface, mask: byte){.cdecl, importc: "SDL_WM_SetIcon", 
-    dynlib: LibName.}
-  # This function iconifies the window, and returns 1 if it succeeded.
-  #  If the function succeeds, it generates an SDL_APPACTIVE loss event.
-  #  This function is a noop and returns 0 in non-windowed environments.
-proc wmIconifyWindow*(): int{.cdecl, importc: "SDL_WM_IconifyWindow", 
-                               dynlib: LibName.}
-  # Toggle fullscreen mode without changing the contents of the screen.
-  #  If the display surface does not require locking before accessing
-  #  the pixel information, then the memory pointers will not change.
-  #
-  #  If this function was able to toggle fullscreen mode (change from
-  #  running in a window to fullscreen, or vice-versa), it will return 1.
-  #  If it is not implemented, or fails, it returns 0.
-  #
-  #  The next call to SDL_SetVideoMode() will set the mode fullscreen
-  #  attribute based on the flags parameter - if SDL_FULLSCREEN is not
-  #  set, then the display will be windowed by default where supported.
-  #
-  #  This is currently only implemented in the X11 video driver.
-proc wmToggleFullScreen*(surface: PSurface): int{.cdecl, 
-    importc: "SDL_WM_ToggleFullScreen", dynlib: LibName.}
-  # Grabbing means that the mouse is confined to the application window,
-  #  and nearly all keyboard input is passed directly to the application,
-  #  and not interpreted by a window manager, if any.
-proc wmGrabInput*(mode: GrabMode): GrabMode{.cdecl, 
-    importc: "SDL_WM_GrabInput", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # mouse-routines
-  #------------------------------------------------------------------------------
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  current mouse cursor position.  You can pass NULL for either x or y.
-proc getMouseState*(x: var int, y: var int): byte{.cdecl, 
-    importc: "SDL_GetMouseState", dynlib: LibName.}
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  mouse deltas since the last call to SDL_GetRelativeMouseState().
-proc getRelativeMouseState*(x: var int, y: var int): byte{.cdecl, 
-    importc: "SDL_GetRelativeMouseState", dynlib: LibName.}
-  # Set the position of the mouse cursor (generates a mouse motion event)
-proc warpMouse*(x, y: uint16){.cdecl, importc: "SDL_WarpMouse", dynlib: LibName.}
-  # Create a cursor using the specified data and mask (in MSB format).
-  #  The cursor width must be a multiple of 8 bits.
-  #
-  #  The cursor is created in black and white according to the following:
-  #  data  mask    resulting pixel on screen
-  #   0     1       White
-  #   1     1       Black
-  #   0     0       Transparent
-  #   1     0       Inverted color if possible, black if not.
-  #
-  #  Cursors created with this function must be freed with SDL_FreeCursor().
-proc createCursor*(data, mask: ptr byte, w, h, hotX, hotY: int): PCursor{.cdecl, 
-    importc: "SDL_CreateCursor", dynlib: LibName.}
-  # Set the currently active cursor to the specified one.
-  #  If the cursor is currently visible, the change will be immediately
-  #  represented on the display.
-proc setCursor*(cursor: PCursor){.cdecl, importc: "SDL_SetCursor", 
-                                  dynlib: LibName.}
-  # Returns the currently active cursor.
-proc getCursor*(): PCursor{.cdecl, importc: "SDL_GetCursor", dynlib: LibName.}
-  # Deallocates a cursor created with SDL_CreateCursor().
-proc freeCursor*(cursor: PCursor){.cdecl, importc: "SDL_FreeCursor", 
-                                   dynlib: LibName.}
-  # Toggle whether or not the cursor is shown on the screen.
-  #  The cursor start off displayed, but can be turned off.
-  #  SDL_ShowCursor() returns 1 if the cursor was being displayed
-  #  before the call, or 0 if it was not.  You can query the current
-  #  state by passing a 'toggle' value of -1.
-proc showCursor*(toggle: int): int{.cdecl, importc: "SDL_ShowCursor", 
-                                    dynlib: LibName.}
-proc button*(b: int): int
-  #------------------------------------------------------------------------------
-  # Keyboard-routines
-  #------------------------------------------------------------------------------
-  # Enable/Disable UNICODE translation of keyboard input.
-  #  This translation has some overhead, so translation defaults off.
-  #  If 'enable' is 1, translation is enabled.
-  #  If 'enable' is 0, translation is disabled.
-  #  If 'enable' is -1, the translation state is not changed.
-  #  It returns the previous state of keyboard translation.
-proc enableUNICODE*(enable: int): int{.cdecl, importc: "SDL_EnableUNICODE", 
-                                       dynlib: LibName.}
-  # If 'delay' is set to 0, keyboard repeat is disabled.
-proc enableKeyRepeat*(delay: int, interval: int): int{.cdecl, 
-    importc: "SDL_EnableKeyRepeat", dynlib: LibName.}
-proc getKeyRepeat*(delay: PInteger, interval: PInteger){.cdecl, 
-    importc: "SDL_GetKeyRepeat", dynlib: LibName.}
-  # Get a snapshot of the current state of the keyboard.
-  #  Returns an array of keystates, indexed by the SDLK_* syms.
-  #  Used:
-  #
-  #  byte *keystate = SDL_GetKeyState(NULL);
-  #  if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed
-proc getKeyState*(numkeys: pointer): ptr byte{.cdecl, importc: "SDL_GetKeyState", 
-    dynlib: LibName.}
-  # Get the current key modifier state
-proc getModState*(): Mod{.cdecl, importc: "SDL_GetModState", dynlib: LibName.}
-  # Set the current key modifier state
-  #  This does not change the keyboard state, only the key modifier flags.
-proc setModState*(modstate: Mod){.cdecl, importc: "SDL_SetModState", 
-                                   dynlib: LibName.}
-  # Get the name of an SDL virtual keysym
-proc getKeyName*(key: Key): cstring{.cdecl, importc: "SDL_GetKeyName", 
-                                      dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Active Routines
-  #------------------------------------------------------------------------------
-  # This function returns the current state of the application, which is a
-  #  bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
-  #  SDL_APPACTIVE.  If SDL_APPACTIVE is set, then the user is able to
-  #  see your application, otherwise it has been iconified or disabled.
-proc getAppState*(): byte{.cdecl, importc: "SDL_GetAppState", dynlib: LibName.}
-  # Mutex functions
-  # Create a mutex, initialized unlocked
-proc createMutex*(): PMutex{.cdecl, importc: "SDL_CreateMutex", dynlib: LibName.}
-  # Lock the mutex  (Returns 0, or -1 on error)
-proc mutexP*(mutex: PMutex): int{.cdecl, importc: "SDL_mutexP", dynlib: LibName.}
-proc lockMutex*(mutex: PMutex): int
-  # Unlock the mutex  (Returns 0, or -1 on error)
-proc mutexV*(mutex: PMutex): int{.cdecl, importc: "SDL_mutexV", dynlib: LibName.}
-proc unlockMutex*(mutex: PMutex): int
-  # Destroy a mutex
-proc destroyMutex*(mutex: PMutex){.cdecl, importc: "SDL_DestroyMutex", 
-                                   dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Semaphore functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a semaphore, initialized with value, returns NULL on failure.
-proc createSemaphore*(initialValue: int32): PSem{.cdecl, 
-    importc: "SDL_CreateSemaphore", dynlib: LibName.}
-  # Destroy a semaphore
-proc destroySemaphore*(sem: PSem){.cdecl, importc: "SDL_DestroySemaphore", 
-                                   dynlib: LibName.}
-  # This function suspends the calling thread until the semaphore pointed
-  #  to by sem has a positive count. It then atomically decreases the semaphore
-  #  count.
-proc semWait*(sem: PSem): int{.cdecl, importc: "SDL_SemWait", dynlib: LibName.}
-  # Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
-  #   SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
-proc semTryWait*(sem: PSem): int{.cdecl, importc: "SDL_SemTryWait", 
-                                  dynlib: LibName.}
-  # Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
-  #   the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
-  #   the allotted time, and -1 on error.
-  #   On some platforms this function is implemented by looping with a delay
-  #   of 1 ms, and so should be avoided if possible.
-proc semWaitTimeout*(sem: PSem, ms: int32): int{.cdecl, 
-    importc: "SDL_SemWaitTimeout", dynlib: LibName.}
-  # Atomically increases the semaphore's count (not blocking), returns 0,
-  #   or -1 on error.
-proc semPost*(sem: PSem): int{.cdecl, importc: "SDL_SemPost", dynlib: LibName.}
-  # Returns the current count of the semaphore
-proc semValue*(sem: PSem): int32{.cdecl, importc: "SDL_SemValue", 
-                                   dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a condition variable
-proc createCond*(): PCond{.cdecl, importc: "SDL_CreateCond", dynlib: LibName.}
-  # Destroy a condition variable
-proc destroyCond*(cond: PCond){.cdecl, importc: "SDL_DestroyCond", 
-                                dynlib: LibName.}
-  # Restart one of the threads that are waiting on the condition variable,
-  #   returns 0 or -1 on error.
-proc condSignal*(cond: PCond): int{.cdecl, importc: "SDL_CondSignal", 
-                                    dynlib: LibName.}
-  # Restart all threads that are waiting on the condition variable,
-  #  returns 0 or -1 on error.
-proc condBroadcast*(cond: PCond): int{.cdecl, importc: "SDL_CondBroadcast", 
-                                       dynlib: LibName.}
-  # Wait on the condition variable, unlocking the provided mutex.
-  #  The mutex must be locked before entering this function!
-  #  Returns 0 when it is signaled, or -1 on error.
-proc condWait*(cond: PCond, mut: PMutex): int{.cdecl, importc: "SDL_CondWait", 
-    dynlib: LibName.}
-  # Waits for at most 'ms' milliseconds, and returns 0 if the condition
-  #  variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
-  #  signaled in the allotted time, and -1 on error.
-  #  On some platforms this function is implemented by looping with a delay
-  #  of 1 ms, and so should be avoided if possible.
-proc condWaitTimeout*(cond: PCond, mut: PMutex, ms: int32): int{.cdecl, 
-    importc: "SDL_CondWaitTimeout", dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a thread
-proc createThread*(fn, data: pointer): PThread{.cdecl, 
-    importc: "SDL_CreateThread", dynlib: LibName.}
-  # Get the 32-bit thread identifier for the current thread
-proc threadID*(): int32{.cdecl, importc: "SDL_ThreadID", dynlib: LibName.}
-  # Get the 32-bit thread identifier for the specified thread,
-  #  equivalent to SDL_ThreadID() if the specified thread is NULL.
-proc getThreadID*(thread: PThread): int32{.cdecl, importc: "SDL_GetThreadID", 
-    dynlib: LibName.}
-  # Wait for a thread to finish.
-  #  The return code for the thread function is placed in the area
-  #  pointed to by 'status', if 'status' is not NULL.
-proc waitThread*(thread: PThread, status: var int){.cdecl, 
-    importc: "SDL_WaitThread", dynlib: LibName.}
-  # Forcefully kill a thread without worrying about its state
-proc killThread*(thread: PThread){.cdecl, importc: "SDL_KillThread", 
-                                   dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Get Environment Routines
-  #------------------------------------------------------------------------------
-  #*
-  # * This function gives you custom hooks into the window manager information.
-  # * It fills the structure pointed to by 'info' with custom information and
-  # * returns 1 if the function is implemented.  If it's not implemented, or
-  # * the version member of the 'info' structure is invalid, it returns 0.
-  # *
-proc getWMInfo*(info: PSysWMinfo): int{.cdecl, importc: "SDL_GetWMInfo", 
-                                        dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  #SDL_loadso.h
-  #* This function dynamically loads a shared object and returns a pointer
-  # * to the object handle (or NULL if there was an error).
-  # * The 'sofile' parameter is a system dependent name of the object file.
-  # *
-proc loadObject*(sofile: cstring): pointer{.cdecl, importc: "SDL_LoadObject", 
-    dynlib: LibName.}
-  #* Given an object handle, this function looks up the address of the
-  # * named function in the shared object and returns it.  This address
-  # * is no longer valid after calling SDL_UnloadObject().
-  # *
-proc loadFunction*(handle: pointer, name: cstring): pointer{.cdecl, 
-    importc: "SDL_LoadFunction", dynlib: LibName.}
-  #* Unload a shared object from memory *
-proc unloadObject*(handle: pointer){.cdecl, importc: "SDL_UnloadObject", 
-                                     dynlib: LibName.}
-  #------------------------------------------------------------------------------
-proc swap32*(d: int32): int32
-  # Bitwise Checking functions
-proc isBitOn*(value: int, bit: int8): bool
-proc turnBitOn*(value: int, bit: int8): int
-proc turnBitOff*(value: int, bit: int8): int
-# implementation
-
-proc tablesize(table: cstring): int = 
-  result = sizeOf(table) div sizeOf(table[0])
-
-proc rwSeek(context: PRWops, offset: int, whence: int): int = 
-  result = context.seek(context, offset, whence)
-
-proc rwTell(context: PRWops): int = 
-  result = context.seek(context, 0, 1)
-
-proc rwRead(context: PRWops, theptr: pointer, size: int, n: int): int = 
-  result = context.read(context, theptr, size, n)
-
-proc rwWrite(context: PRWops, theptr: pointer, size: int, n: int): int = 
-  result = context.write(context, theptr, size, n)
-
-proc rwClose(context: PRWops): int = 
-  result = context.closeFile(context)
-
-proc loadWAV(filename: cstring, spec: PAudioSpec, audioBuf: ptr byte, 
-             audiolen: PUInt32): PAudioSpec = 
-  result = loadWAV_RW(rWFromFile(filename, "rb"), 1, spec, audioBuf, audiolen)
-
-proc cdInDrive(status: CDStatus): bool = 
-  result = ord(status) > ord(CD_ERROR)
-
-proc framesToMsf*(frames: int; m, s, f: var int) =
-  var value = frames
-  f = value mod CD_FPS
-  value = value div CD_FPS
-  s = value mod 60
-  value = value div 60
-  m = value
-
-proc msfToFrames*(m, s, f: int): int = 
-  result = m * 60 * CD_FPS + s * CD_FPS + f
-
-proc version(x: var Version) = 
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-proc versionnum(x, y, z: int): int = 
-  result = x * 1000 + y * 100 + z
-
-proc compiledversion(): int = 
-  result = versionnum(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL)
-
-proc versionAtleast(x, y, z: int): bool = 
-  result = (compiledversion() >= versionnum(x, y, z))
-
-proc loadBMP(filename: cstring): PSurface = 
-  result = loadBMP_RW(rWFromFile(filename, "rb"), 1)
-
-proc saveBMP(surface: PSurface, filename: cstring): int = 
-  result = saveBMP_RW(surface, rWFromFile(filename, "wb"), 1)
-
-proc blitSurface(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int = 
-  result = upperBlit(src, srcrect, dst, dstrect)
-
-proc allocSurface(flags: int32, width, height, depth: int, 
-                  rMask, gMask, bMask, aMask: int32): PSurface = 
-  result = createRGBSurface(flags, width, height, depth, rMask, gMask, bMask, 
-                            aMask)
-
-proc mustLock(surface: PSurface): bool = 
-  result = ((surface.offset != 0) or
-      ((surface.flags and (HWSURFACE or ASYNCBLIT or RLEACCEL)) != 0))
-
-proc lockMutex(mutex: PMutex): int = 
-  result = mutexP(mutex)
-
-proc unlockMutex(mutex: PMutex): int = 
-  result = mutexV(mutex)
-
-proc button(b: int): int = 
-  result = PRESSED shl (b - 1)
-
-proc swap32(d: int32): int32 = 
-  result = ((d shl 24) or ((d shl 8) and 0x00FF0000) or
-      ((d shr 8) and 0x0000FF00) or (d shr 24))
-
-proc isBitOn(value: int, bit: int8): bool = 
-  result = ((value and (1 shl ze(bit))) != 0)
-
-proc turnBitOn(value: int, bit: int8): int = 
-  result = (value or (1 shl ze(bit)))
-
-proc turnBitOff(value: int, bit: int8): int = 
-  result = (value and not (1 shl ze(bit)))
diff --git a/lib/wrappers/sdl/sdl_gfx.nim b/lib/wrappers/sdl/sdl_gfx.nim
deleted file mode 100644
index 0f5afaa9b..000000000
--- a/lib/wrappers/sdl/sdl_gfx.nim
+++ /dev/null
@@ -1,452 +0,0 @@
-#
-#  $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
-#
-#
-#
-#  $Log: sdl_gfx.pas,v $
-#  Revision 1.3  2007/05/29 21:31:04  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.2  2007/05/20 20:30:18  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.1  2005/01/03 19:08:32  savage
-#  Header for the SDL_Gfx library.
-#
-#
-#
-#
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    gfxLibName = "SDL_gfx.dll"
-elif defined(macosx): 
-  const 
-    gfxLibName = "libSDL_gfx.dylib"
-else: 
-  const 
-    gfxLibName = "libSDL_gfx.so"
-const                         # Some rates in Hz
-  FPS_UPPER_LIMIT* = 200
-  FPS_LOWER_LIMIT* = 1
-  FPS_DEFAULT* = 30           # ---- Defines
-  SMOOTHING_OFF* = 0
-  SMOOTHING_ON* = 1
-
-type 
-  PFPSmanager* = ptr FPSmanager
-  FPSmanager*{.final.} = object  # ---- Structures
-    framecount*: uint32
-    rateticks*: float32
-    lastticks*: uint32
-    rate*: uint32
-
-  PColorRGBA* = ptr ColorRGBA
-  ColorRGBA*{.final.} = object 
-    r*: byte
-    g*: byte
-    b*: byte
-    a*: byte
-
-  PColorY* = ptr ColorY
-  ColorY*{.final.} = object   #
-                              #
-                              # SDL_framerate: framerate manager
-                              #
-                              # LGPL (c) A. Schiffler
-                              #
-                              #
-    y*: byte
-{.deprecated: [TFPSmanager: FPSmanager, TColorRGBA: ColorRGBA, TColorY: ColorY].}
-
-proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate", 
-    dynlib: gfxLibName.}
-proc setFramerate*(manager: PFPSmanager, rate: cint): cint{.cdecl, 
-    importc: "SDL_setFramerate", dynlib: gfxLibName.}
-proc getFramerate*(manager: PFPSmanager): cint{.cdecl, 
-    importc: "SDL_getFramerate", dynlib: gfxLibName.}
-proc framerateDelay*(manager: PFPSmanager){.cdecl, 
-    importc: "SDL_framerateDelay", dynlib: gfxLibName.}
-  #
-  #
-  # SDL_gfxPrimitives: graphics primitives for SDL
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Note: all ___Color routines expect the color to be in format 0xRRGGBBAA 
-  # Pixel 
-proc pixelColor*(dst: PSurface, x: int16, y: int16, color: uint32): cint{.
-    cdecl, importc: "pixelColor", dynlib: gfxLibName.}
-proc pixelRGBA*(dst: PSurface, x: int16, y: int16, r: byte, g: byte, 
-                b: byte, a: byte): cint{.cdecl, importc: "pixelRGBA", 
-    dynlib: gfxLibName.}
-  # Horizontal line 
-proc hlineColor*(dst: PSurface, x1: int16, x2: int16, y: int16, color: uint32): cint{.
-    cdecl, importc: "hlineColor", dynlib: gfxLibName.}
-proc hlineRGBA*(dst: PSurface, x1: int16, x2: int16, y: int16, r: byte, 
-                g: byte, b: byte, a: byte): cint{.cdecl, importc: "hlineRGBA", 
-    dynlib: gfxLibName.}
-  # Vertical line 
-proc vlineColor*(dst: PSurface, x: int16, y1: int16, y2: int16, color: uint32): cint{.
-    cdecl, importc: "vlineColor", dynlib: gfxLibName.}
-proc vlineRGBA*(dst: PSurface, x: int16, y1: int16, y2: int16, r: byte, 
-                g: byte, b: byte, a: byte): cint{.cdecl, importc: "vlineRGBA", 
-    dynlib: gfxLibName.}
-  # Rectangle 
-proc rectangleColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                     y2: int16, color: uint32): cint{.cdecl, 
-    importc: "rectangleColor", dynlib: gfxLibName.}
-proc rectangleRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                    y2: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "rectangleRGBA", dynlib: gfxLibName.}
-  # Filled rectangle (Box) 
-proc boxColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-               color: uint32): cint{.cdecl, importc: "boxColor", 
-                                    dynlib: gfxLibName.}
-proc boxRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-              r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "boxRGBA", dynlib: gfxLibName.}
-  # Line 
-proc lineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                color: uint32): cint{.cdecl, importc: "lineColor", 
-                                     dynlib: gfxLibName.}
-proc lineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-               r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "lineRGBA", dynlib: gfxLibName.}
-  # AA Line 
-proc aalineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                  color: uint32): cint{.cdecl, importc: "aalineColor", 
-                                       dynlib: gfxLibName.}
-proc aalineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aalineRGBA", dynlib: gfxLibName.}
-  # Circle 
-proc circleColor*(dst: PSurface, x: int16, y: int16, r: int16, color: uint32): cint{.
-    cdecl, importc: "circleColor", dynlib: gfxLibName.}
-proc circleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
-                 g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "circleRGBA", dynlib: gfxLibName.}
-  # AA Circle 
-proc aacircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
-                    color: uint32): cint{.cdecl, importc: "aacircleColor", 
-    dynlib: gfxLibName.}
-proc aacircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
-                   g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aacircleRGBA", dynlib: gfxLibName.}
-  # Filled Circle 
-proc filledCircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
-                        color: uint32): cint{.cdecl, 
-    importc: "filledCircleColor", dynlib: gfxLibName.}
-proc filledCircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                       r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "filledCircleRGBA", dynlib: gfxLibName.}
-  # Ellipse 
-proc ellipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                   color: uint32): cint{.cdecl, importc: "ellipseColor", 
-                                        dynlib: gfxLibName.}
-proc ellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                  r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "ellipseRGBA", dynlib: gfxLibName.}
-  # AA Ellipse 
-proc aaellipseColor*(dst: PSurface, xc: int16, yc: int16, rx: int16, 
-                     ry: int16, color: uint32): cint{.cdecl, 
-    importc: "aaellipseColor", dynlib: gfxLibName.}
-proc aaellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                    r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aaellipseRGBA", dynlib: gfxLibName.}
-  # Filled Ellipse 
-proc filledEllipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, 
-                         ry: int16, color: uint32): cint{.cdecl, 
-    importc: "filledEllipseColor", dynlib: gfxLibName.}
-proc filledEllipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, 
-                        ry: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "filledEllipseRGBA", dynlib: gfxLibName.}
-  # Pie
-proc pieColor*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
-               finish: int16, color: uint32): cint{.cdecl, importc: "pieColor", 
-    dynlib: gfxLibName.}
-proc pieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
-              finish: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "pieRGBA", dynlib: gfxLibName.}
-  # Filled Pie
-proc filledPieColor*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                     start: int16, finish: int16, color: uint32): cint{.cdecl, 
-    importc: "filledPieColor", dynlib: gfxLibName.}
-proc filledPieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                    start: int16, finish: int16, r: byte, g: byte, b: byte, 
-                    a: byte): cint{.cdecl, importc: "filledPieRGBA", 
-                                    dynlib: gfxLibName.}
-  # Trigon
-proc trigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                  x3: int16, y3: int16, color: uint32): cint{.cdecl, 
-    importc: "trigonColor", dynlib: gfxLibName.}
-proc trigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                 x3: int16, y3: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "trigonRGBA", dynlib: gfxLibName.}
-  # AA-Trigon
-proc aatrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                    y2: int16, x3: int16, y3: int16, color: uint32): cint{.
-    cdecl, importc: "aatrigonColor", dynlib: gfxLibName.}
-proc aatrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                   y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
-                   b: byte, a: byte): cint{.cdecl, importc: "aatrigonRGBA", 
-    dynlib: gfxLibName.}
-  # Filled Trigon
-proc filledTrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                        y2: int16, x3: int16, y3: int16, color: uint32): cint{.
-    cdecl, importc: "filledTrigonColor", dynlib: gfxLibName.}
-proc filledTrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                       y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
-                       b: byte, a: byte): cint{.cdecl, 
-    importc: "filledTrigonRGBA", dynlib: gfxLibName.}
-  # Polygon
-proc polygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                   color: uint32): cint{.cdecl, importc: "polygonColor", 
-                                        dynlib: gfxLibName.}
-proc polygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
-                  g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "polygonRGBA", dynlib: gfxLibName.}
-  # AA-Polygon
-proc aapolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                     color: uint32): cint{.cdecl, importc: "aapolygonColor", 
-    dynlib: gfxLibName.}
-proc aapolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
-                    g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aapolygonRGBA", dynlib: gfxLibName.}
-  # Filled Polygon
-proc filledPolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                         color: uint32): cint{.cdecl, 
-    importc: "filledPolygonColor", dynlib: gfxLibName.}
-proc filledPolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                        r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "filledPolygonRGBA", dynlib: gfxLibName.}
-  # Bezier
-  # s = number of steps
-proc bezierColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
-                  color: uint32): cint{.cdecl, importc: "bezierColor", 
-                                       dynlib: gfxLibName.}
-proc bezierRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
-                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "bezierRGBA", dynlib: gfxLibName.}
-  # Characters/Strings
-proc characterColor*(dst: PSurface, x: int16, y: int16, c: char, color: uint32): cint{.
-    cdecl, importc: "characterColor", dynlib: gfxLibName.}
-proc characterRGBA*(dst: PSurface, x: int16, y: int16, c: char, r: byte, 
-                    g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "characterRGBA", dynlib: gfxLibName.}
-proc stringColor*(dst: PSurface, x: int16, y: int16, c: cstring, color: uint32): cint{.
-    cdecl, importc: "stringColor", dynlib: gfxLibName.}
-proc stringRGBA*(dst: PSurface, x: int16, y: int16, c: cstring, r: byte, 
-                 g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "stringRGBA", dynlib: gfxLibName.}
-proc gfxPrimitivesSetFont*(fontdata: pointer, cw: cint, ch: cint){.cdecl, 
-    importc: "gfxPrimitivesSetFont", dynlib: gfxLibName.}
-  #
-  #
-  # SDL_imageFilter - bytes-image "filter" routines
-  # (uses inline x86 MMX optimizations if available)
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Comments:                                                                           
-  #  1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. 
-  #  2.) Data that is not within an 8 byte boundary is processed using the C routine.   
-  #  3.) Convolution routines do not have C routines at this time.                      
-  # Detect MMX capability in CPU
-proc imageFilterMMXdetect*(): cint{.cdecl, importc: "SDL_imageFilterMMXdetect", 
-                                   dynlib: gfxLibName.}
-  # Force use of MMX off (or turn possible use back on)
-proc imageFilterMMXoff*(){.cdecl, importc: "SDL_imageFilterMMXoff", 
-                           dynlib: gfxLibName.}
-proc imageFilterMMXon*(){.cdecl, importc: "SDL_imageFilterMMXon", 
-                          dynlib: gfxLibName.}
-  #
-  # All routines return:
-  #   0   OK
-  #  -1   Error (internal error, parameter error)
-  #
-  #  SDL_imageFilterAdd: D = saturation255(S1 + S2)
-proc imageFilterAdd*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAdd", dynlib: gfxLibName.}
-  #  SDL_imageFilterMean: D = S1/2 + S2/2
-proc imageFilterMean*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMean", dynlib: gfxLibName.}
-  #  SDL_imageFilterSub: D = saturation0(S1 - S2)
-proc imageFilterSub*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSub", dynlib: gfxLibName.}
-  #  SDL_imageFilterAbsDiff: D = | S1 - S2 |
-proc imageFilterAbsDiff*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAbsDiff", dynlib: gfxLibName.}
-  #  SDL_imageFilterMult: D = saturation(S1 * S2)
-proc imageFilterMult*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMult", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultNor: D = S1 * S2   (non-MMX)
-proc imageFilterMultNor*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMultNor", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
-proc imageFilterMultDivby2*(src1: cstring, src2: cstring, dest: cstring, 
-                            len: cint): cint{.cdecl, 
-    importc: "SDL_imageFilterMultDivby2", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
-proc imageFilterMultDivby4*(src1: cstring, src2: cstring, dest: cstring, 
-                            len: cint): cint{.cdecl, 
-    importc: "SDL_imageFilterMultDivby4", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitAnd: D = S1 & S2
-proc imageFilterBitAnd*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitAnd", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitOr: D = S1 | S2
-proc imageFilterBitOr*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitOr", dynlib: gfxLibName.}
-  #  SDL_imageFilterDiv: D = S1 / S2   (non-MMX)
-proc imageFilterDiv*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterDiv", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitNegation: D = !S
-proc imageFilterBitNegation*(src1: cstring, dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitNegation", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddByte: D = saturation255(S + C)
-proc imageFilterAddByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
-    cdecl, importc: "SDL_imageFilterAddByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
-proc imageFilterAddUint*(src1: cstring, dest: cstring, len: cint, c: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAddUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
-proc imageFilterAddByteToHalf*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
-    cdecl, importc: "SDL_imageFilterAddByteToHalf", dynlib: gfxLibName.}
-  #  SDL_imageFilterSubByte: D = saturation0(S - C)
-proc imageFilterSubByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
-    cdecl, importc: "SDL_imageFilterSubByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
-proc imageFilterSubUint*(src1: cstring, dest: cstring, len: cint, c: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSubUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRight: D = saturation0(S >> N)
-proc imageFilterShiftRight*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
-proc imageFilterShiftRightUint*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftRightUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultByByte: D = saturation255(S * C)
-proc imageFilterMultByByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
-    cdecl, importc: "SDL_imageFilterMultByByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
-proc imageFilterShiftRightAndMultByByte*(src1: cstring, dest: cstring, len: cint, 
-    n: char, c: char): cint{.cdecl, 
-                            importc: "SDL_imageFilterShiftRightAndMultByByte", 
-                            dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeftByte: D = (S << N)
-proc imageFilterShiftLeftByte*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeftByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
-proc imageFilterShiftLeftUint*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeftUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeft: D = saturation255(S << N)
-proc imageFilterShiftLeft*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeft", dynlib: gfxLibName.}
-  #  SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
-proc imageFilterBinarizeUsingThreshold*(src1: cstring, dest: cstring, len: cint, 
-                                        t: char): cint{.cdecl, 
-    importc: "SDL_imageFilterBinarizeUsingThreshold", dynlib: gfxLibName.}
-  #  SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
-proc imageFilterClipToRange*(src1: cstring, dest: cstring, len: cint, tmin: int8, 
-                             tmax: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterClipToRange", dynlib: gfxLibName.}
-  #  SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
-proc imageFilterNormalizeLinear*(src1: cstring, dest: cstring, len: cint, 
-                                 cmin: cint, cmax: cint, nmin: cint, nmax: cint): cint{.
-    cdecl, importc: "SDL_imageFilterNormalizeLinear", dynlib: gfxLibName.}
-  # !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! 
-  #  SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel3x3Divide*(src: cstring, dest: cstring, rows: cint, 
-    columns: cint, kernel: pointer, divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel3x3Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel5x5Divide*(src: cstring, dest: cstring, rows: cint, 
-    columns: cint, kernel: pointer, divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel5x5Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel7x7Divide*(src: cstring, dest: cstring, rows: cint, 
-    columns: cint, kernel: pointer, divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel7x7Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel9x9Divide*(src: cstring, dest: cstring, rows: cint, 
-    columns: cint, kernel: pointer, divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel9x9Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel3x3ShiftRight*(src: cstring, dest: cstring, 
-    rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel3x3ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel5x5ShiftRight*(src: cstring, dest: cstring, 
-    rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel5x5ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel7x7ShiftRight*(src: cstring, dest: cstring, 
-    rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel7x7ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel9x9ShiftRight*(src: cstring, dest: cstring, 
-    rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel9x9ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterSobelX: Dij = saturation255( ... )
-proc imageFilterSobelX*(src: cstring, dest: cstring, rows: cint, columns: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSobelX", dynlib: gfxLibName.}
-  #  SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
-proc imageFilterSobelXShiftRight*(src: cstring, dest: cstring, rows: cint, 
-                                  columns: cint, nRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterSobelXShiftRight", dynlib: gfxLibName.}
-  # Align/restore stack to 32 byte boundary -- Functionality untested! --
-proc imageFilterAlignStack*(){.cdecl, importc: "SDL_imageFilterAlignStack", 
-                               dynlib: gfxLibName.}
-proc imageFilterRestoreStack*(){.cdecl, importc: "SDL_imageFilterRestoreStack", 
-                                 dynlib: gfxLibName.}
-  #
-  #
-  # SDL_rotozoom - rotozoomer
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # 
-  # 
-  # rotozoomSurface()
-  #
-  # Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc rotozoomSurface*(src: PSurface, angle: float64, zoom: float64, smooth: cint): PSurface{.
-    cdecl, importc: "rotozoomSurface", dynlib: gfxLibName.}
-proc rotozoomSurfaceXY*(src: PSurface, angle: float64, zoomx: float64, 
-                        zoomy: float64, smooth: cint): PSurface{.cdecl, 
-    importc: "rotozoomSurfaceXY", dynlib: gfxLibName.}
-  # Returns the size of the target surface for a rotozoomSurface() call 
-proc rotozoomSurfaceSize*(width: cint, height: cint, angle: float64, 
-                          zoom: float64, dstwidth: var cint, dstheight: var cint){.
-    cdecl, importc: "rotozoomSurfaceSize", dynlib: gfxLibName.}
-proc rotozoomSurfaceSizeXY*(width: cint, height: cint, angle: float64, 
-                            zoomx: float64, zoomy: float64, dstwidth: var cint, 
-                            dstheight: var cint){.cdecl, 
-    importc: "rotozoomSurfaceSizeXY", dynlib: gfxLibName.}
-  #
-  #
-  # zoomSurface()
-  #
-  # Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc zoomSurface*(src: PSurface, zoomx: float64, zoomy: float64, smooth: cint): PSurface{.
-    cdecl, importc: "zoomSurface", dynlib: gfxLibName.}
-  # Returns the size of the target surface for a zoomSurface() call 
-proc zoomSurfaceSize*(width: cint, height: cint, zoomx: float64, zoomy: float64, 
-                      dstwidth: var cint, dstheight: var cint){.cdecl, 
-    importc: "zoomSurfaceSize", dynlib: gfxLibName.}
-# implementation
diff --git a/lib/wrappers/sdl/sdl_image.nim b/lib/wrappers/sdl/sdl_image.nim
deleted file mode 100644
index 7f99c8069..000000000
--- a/lib/wrappers/sdl/sdl_image.nim
+++ /dev/null
@@ -1,243 +0,0 @@
-#
-#  $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
-#  
-#
-#******************************************************************************
-#                                                                              
-#       Borland Delphi SDL_Image - An example image loading library for use    
-#                                  with SDL                                    
-#       Conversion of the Simple DirectMedia Layer Image Headers               
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_image.h                                         
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Dominique Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#   A simple library to load images of various formats as SDL surfaces         
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas in your search path.                                               
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#   See the Aliens Demo on how to make use of this libaray                     
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April    02 2001 - MT : Initial Translation                                
-#                                                                              
-#   May      08 2001 - DL : Added ExternalSym derectives and copyright header  
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_image.pas,v $
-#  Revision 1.14  2007/05/29 21:31:13  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.13  2007/05/20 20:30:54  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.12  2006/12/02 00:14:40  savage
-#  Updated to latest version
-#
-#  Revision 1.11  2005/04/10 18:22:59  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.10  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.9  2005/01/05 01:47:07  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.8  2005/01/04 23:14:44  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.7  2005/01/01 02:03:12  savage
-#  Updated to v1.2.4
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows):
-  const
-    ImageLibName = "SDL_Image.dll"
-elif defined(macosx):
-  const
-    ImageLibName = "libSDL_image-1.2.0.dylib"
-else:
-  const
-    ImageLibName = "libSDL_image(.so|-1.2.so.0)"
-const
-  IMAGE_MAJOR_VERSION* = 1
-  IMAGE_MINOR_VERSION* = 2
-  IMAGE_PATCHLEVEL* = 5
-
-# This macro can be used to fill a version structure with the compile-time
-#  version of the SDL_image library. 
-
-proc imageVersion*(x: var Version)
-  # This function gets the version of the dynamically linked SDL_image library.
-  #   it should NOT be used to fill a version structure, instead you should
-  #   use the SDL_IMAGE_VERSION() macro.
-  # 
-proc imgLinkedVersion*(): Pversion{.importc: "IMG_Linked_Version", 
-                                    dynlib: ImageLibName.}
-  # Load an image from an SDL data source.
-  #   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
-  #
-  #   If the image format supports a transparent pixel, SDL will set the
-  #   colorkey for the surface.  You can enable RLE acceleration on the
-  #   surface afterwards by calling:
-  #        SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
-  #
-
-const
-  IMG_INIT_JPG* = 0x00000001
-  IMG_INIT_PNG* = 0x00000002
-  IMG_INIT_TIF* = 0x00000004
-  IMG_INIT_WEBP* = 0x00000008
-
-proc imgInit*(flags: cint): int {.cdecl, importc: "IMG_Init",
-                                  dynlib: ImageLibName.}
-proc imgQuit*() {.cdecl, importc: "IMG_Quit",
-                                  dynlib: ImageLibName.}
-proc imgLoadTypedRW*(src: PRWops, freesrc: cint, theType: cstring): PSurface{.
-    cdecl, importc: "IMG_LoadTyped_RW", dynlib: ImageLibName.}
-  # Convenience functions 
-proc imgLoad*(theFile: cstring): PSurface{.cdecl, importc: "IMG_Load", 
-    dynlib: ImageLibName.}
-proc imgLoadRW*(src: PRWops, freesrc: cint): PSurface{.cdecl, 
-    importc: "IMG_Load_RW", dynlib: ImageLibName.}
-  # Invert the alpha of a surface for use with OpenGL
-  #  This function is now a no-op, and only provided for backwards compatibility. 
-proc imgInvertAlpha*(theOn: cint): cint{.cdecl, importc: "IMG_InvertAlpha", 
-                                        dynlib: ImageLibName.}
-  # Functions to detect a file type, given a seekable source 
-proc imgIsBMP*(src: PRWops): cint{.cdecl, importc: "IMG_isBMP", 
-                                   dynlib: ImageLibName.}
-proc imgIsGIF*(src: PRWops): cint{.cdecl, importc: "IMG_isGIF", 
-                                   dynlib: ImageLibName.}
-proc imgIsJPG*(src: PRWops): cint{.cdecl, importc: "IMG_isJPG", 
-                                   dynlib: ImageLibName.}
-proc imgIsLBM*(src: PRWops): cint{.cdecl, importc: "IMG_isLBM", 
-                                   dynlib: ImageLibName.}
-proc imgIsPCX*(src: PRWops): cint{.cdecl, importc: "IMG_isPCX", 
-                                   dynlib: ImageLibName.}
-proc imgIsPNG*(src: PRWops): cint{.cdecl, importc: "IMG_isPNG", 
-                                   dynlib: ImageLibName.}
-proc imgIsPNM*(src: PRWops): cint{.cdecl, importc: "IMG_isPNM", 
-                                   dynlib: ImageLibName.}
-proc imgIsTIF*(src: PRWops): cint{.cdecl, importc: "IMG_isTIF", 
-                                   dynlib: ImageLibName.}
-proc imgIsXCF*(src: PRWops): cint{.cdecl, importc: "IMG_isXCF", 
-                                   dynlib: ImageLibName.}
-proc imgIsXPM*(src: PRWops): cint{.cdecl, importc: "IMG_isXPM", 
-                                   dynlib: ImageLibName.}
-proc imgIsXV*(src: PRWops): cint{.cdecl, importc: "IMG_isXV", 
-                                  dynlib: ImageLibName.}
-  # Individual loading functions 
-proc imgLoadBMP_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadBMP_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadGIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadGIF_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadJPG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadJPG_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadLBM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadLBM_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadPCX_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPCX_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadPNM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNM_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadPNG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNG_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadTGA_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTGA_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadTIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTIF_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadXCF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXCF_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadXPM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXPM_RW", 
-    dynlib: ImageLibName.}
-proc imgLoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW", 
-    dynlib: ImageLibName.}
-proc imgReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl, 
-    importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.}
-
-proc imageVersion(x: var Version) = 
-  x.major = IMAGE_MAJOR_VERSION
-  x.minor = IMAGE_MINOR_VERSION
-  x.patch = IMAGE_PATCHLEVEL
-
diff --git a/lib/wrappers/sdl/sdl_mixer.nim b/lib/wrappers/sdl/sdl_mixer.nim
deleted file mode 100644
index b8f013a4a..000000000
--- a/lib/wrappers/sdl/sdl_mixer.nim
+++ /dev/null
@@ -1,489 +0,0 @@
-#******************************************************************************
-#
-#  $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
-#
-#
-#
-#       Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
-#       Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL_mixer.h
-#                          music_cmd.h
-#                          wavestream.h
-#                          timidity.h
-#                          playmidi.h
-#                          music_ogg.h
-#                          mikmod.h
-#
-# The initial developer of this Pascal code was :
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominqiue Louis are
-# Copyright (C) 2000 - 2001 Dominqiue Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   SDL.pas & SMPEG.pas somewhere within your search path.
-#
-# Programming Notes
-# -----------------
-#   See the Aliens Demo to see how this library is used
-#
-# Revision History
-# ----------------
-#   April    02 2001 - DL : Initial Translation
-#
-#  February  02 2002 - DL : Update to version 1.2.1
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#  $Log: sdl_mixer.pas,v $
-#  Revision 1.18  2007/05/29 21:31:44  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.17  2007/05/20 20:31:17  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.16  2006/12/02 00:16:17  savage
-#  Updated to latest version
-#
-#  Revision 1.15  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.14  2005/02/24 20:20:07  savage
-#  Changed definition of MusicType and added GetMusicType function
-#
-#  Revision 1.13  2005/01/05 01:47:09  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.12  2005/01/04 23:14:56  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.11  2005/01/01 02:05:19  savage
-#  Updated to v1.2.6
-#
-#  Revision 1.10  2004/09/12 21:45:17  savage
-#  Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
-#
-#  Revision 1.9  2004/08/27 21:48:24  savage
-#  IFDEFed out Smpeg support on MacOS X
-#
-#  Revision 1.8  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.7  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.6  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.5  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.4  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.3  2004/03/31 10:05:08  savage
-#  Better defines for Endianness under FreePascal and Borland compilers.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import 
-  sdl, smpeg
-
-when defined(windows): 
-  const 
-    MixerLibName = "SDL_mixer.dll"
-elif defined(macosx): 
-  const 
-    MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else: 
-  const 
-    MixerLibName = "libSDL_mixer.so"
-const 
-  MAJOR_VERSION* = 1
-  MINOR_VERSION* = 2
-  PATCHLEVEL* = 7    # Backwards compatibility
-  
-  CHANNELS* = 8           # Good default values for a PC soundcard
-  DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32): 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16LSB
-else: 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16MSB
-const 
-  DEFAULT_CHANNELS* = 2
-  MAX_VOLUME* = 128       # Volume of a chunk
-  PATH_MAX* = 255             # mikmod.h constants
-                              #*
-                              #  * Library version
-                              #  *
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr MusicCMD
-  MusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr WAVStream
-  WAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: pointer
-    start*: int32
-    stop*: int32
-    cvt*: TAudioCVT
-
-  PMidiEvent* = ptr MidiEvent
-  MidiEvent*{.final.} = object 
-    time*: int32
-    channel*: byte
-    typ*: byte
-    a*: byte
-    b*: byte
-
-  PMidiSong* = ptr MidiSong
-  MidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr OGG_Music
-  OGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: int32
-    volume*: int32              #vf: OggVorbis_File;
-    section*: int32
-    cvt*: TAudioCVT
-    lenAvailable*: int32
-    sndAvailable*: pointer
-
-  ErrorEnum* = enum 
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, 
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, 
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, 
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, 
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, 
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, 
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, 
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, 
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, 
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, 
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, 
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, 
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, 
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, 
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, 
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, 
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, 
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, 
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr MODULE
-  MODULE*{.final.} = object 
-  PUNIMOD* = ptr UNIMOD
-  UNIMOD* = MODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk
-  PChunk* = ptr Chunk
-  Chunk*{.final.} = object 
-    allocated*: cint
-    abuf*: pointer
-    alen*: uint32
-    volume*: byte            # Per-sample volume, 0-128
-  
-  Fading* = enum 
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  MusicType* = enum 
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
-  PMusic* = ptr Music
-  Music*{.final.} = object  # The internal format for a music chunk interpreted via mikmod
-    mixtype*: MusicType      # other fields are not aviable
-                              #    data : MusicUnion;
-                              #    fading : TMix_Fading;
-                              #    fade_volume : integer;
-                              #    fade_step : integer;
-                              #    fade_steps : integer;
-                              #    error : integer;
-  
-  MixFunction* = proc (udata, stream: pointer, length: cint): pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library.
-{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent,
-              TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum,
-              TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading,
-              TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].}
-
-proc version*(x: var sdl.Version)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro.
-proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version", 
-                                      dynlib: MixerLibName.}
-  # Open the mixer with a certain audio format
-proc openAudio*(frequency: cint, format: uint16, channels: cint, 
-                    chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio", 
-    dynlib: MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  #
-proc allocateChannels*(numchannels: cint): cint{.cdecl, 
-    importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  #
-proc querySpec*(frequency: var cint, format: var uint16, channels: var cint): cint{.
-    cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file
-proc loadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl, 
-    importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
-proc loadWAV*(filename: cstring): PChunk
-proc loadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS", 
-    dynlib: MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer
-proc quickLoadWAV*(mem: pointer): PChunk{.cdecl, 
-    importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
-  # Free an audio chunk previously loaded
-proc freeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk", 
-                                        dynlib: MixerLibName.}
-proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", 
-                                        dynlib: MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc getMusicType*(music: PMusic): MusicType{.cdecl, 
-    importc: "Mix_GetMusicType", dynlib: MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc setPostMix*(mixFunc: MixFunction, arg: pointer){.cdecl, 
-    importc: "Mix_SetPostMix", dynlib: MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  #
-proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl, 
-    importc: "Mix_HookMusic", dynlib: MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  #
-proc hookMusicFinished*(musicFinished: pointer){.cdecl, 
-    importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
-  # Get a pointer to the user data for the current music hook
-proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData", 
-                                       dynlib: MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type 
-  ChannelFinished* = proc (channel: cint){.cdecl.}
-{.deprecated: [TChannelFinished: ChannelFinished].}
-
-proc channelFinished*(channelFinished: ChannelFinished){.cdecl, 
-    importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
-const 
-  CHANNEL_POST* = - 2     
-
-type 
-  TEffectFunc* = proc (chan: cint, stream: pointer, length: cint, 
-                       udata: pointer): pointer{.cdecl.}     
-  TEffectDone* = proc (chan: cint, udata: pointer): pointer{.cdecl.} 
-proc registerEffect*(chan: cint, f: TEffectFunc, d: TEffectDone, 
-                         arg: pointer): cint{.cdecl, 
-    importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
-
-proc unregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl, 
-    importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
-
-proc unregisterAllEffects*(channel: cint): cint{.cdecl, 
-    importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
-const 
-  EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
-  
-proc setPanning*(channel: cint, left: byte, right: byte): cint{.cdecl, 
-    importc: "Mix_SetPanning", dynlib: MixerLibName.}
-
-proc setPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetPosition", dynlib: MixerLibName.}
-
-proc setDistance*(channel: cint, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetDistance", dynlib: MixerLibName.}
-
-proc setReverseStereo*(channel: cint, flip: cint): cint{.cdecl, 
-    importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
-
-proc reserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels", 
-    dynlib: MixerLibName.}
-
-proc groupChannel*(which: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannel", dynlib: MixerLibName.}
-proc groupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannels", dynlib: MixerLibName.}
-proc groupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable", 
-    dynlib: MixerLibName.}
-proc groupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount", 
-                                     dynlib: MixerLibName.}
-proc groupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest", 
-                                      dynlib: MixerLibName.}
-proc groupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer", 
-                                     dynlib: MixerLibName.}
-proc playChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                           ticks: cint): cint{.cdecl, 
-    importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
-proc playChannel*(channel: cint, chunk: PChunk, loops: cint): cint
-proc playMusic*(music: PMusic, loops: cint): cint{.cdecl, 
-    importc: "Mix_PlayMusic", dynlib: MixerLibName.}
-proc fadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
-proc fadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                             ms: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
-proc fadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
-
-proc volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume", 
-    dynlib: MixerLibName.}
-proc volumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl, 
-    importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
-proc volumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic", 
-    dynlib: MixerLibName.}
-
-proc haltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel", 
-    dynlib: MixerLibName.}
-proc haltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup", 
-                                    dynlib: MixerLibName.}
-proc haltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic", 
-                            dynlib: MixerLibName.}
-  # Change the expiration delay for a particular channel.
-  #   The sample will stop playing after the 'ticks' milliseconds have elapsed,
-  #   or remove the expiration if 'ticks' is -1
-  #
-proc expireChannel*(channel: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
-  # Halt a channel, fading it out progressively till it's silent
-  #   The ms parameter indicates the number of milliseconds the fading
-  #   will take.
-  #
-proc fadeOutChannel*(which: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
-proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
-proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", 
-                                      dynlib: MixerLibName.}
-  # Query the fading status of a channel
-proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic", 
-                                      dynlib: MixerLibName.}
-proc fadingChannel*(which: cint): Fading{.cdecl, 
-    importc: "Mix_FadingChannel", dynlib: MixerLibName.}
-
-proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
-proc resume*(channel: cint){.cdecl, importc: "Mix_Resume", 
-                                dynlib: MixerLibName.}
-proc paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused", 
-                                     dynlib: MixerLibName.}
-
-proc pauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
-proc resumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
-proc rewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
-proc pausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic", 
-                              dynlib: MixerLibName.}
-
-proc setMusicPosition*(position: float64): cint{.cdecl, 
-    importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
-
-proc playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing", 
-                                      dynlib: MixerLibName.}
-proc playingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic", 
-                               dynlib: MixerLibName.}
-
-proc setMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD", 
-    dynlib: MixerLibName.}
-
-proc setSynchroValue*(value: cint): cint{.cdecl, 
-    importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
-proc getSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue", 
-                                  dynlib: MixerLibName.}
-
-proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", 
-    dynlib: MixerLibName.}
-
-proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
-
-proc version(x: var sdl.Version) = 
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-proc loadWAV(filename: cstring): PChunk = 
-  result = loadWAV_RW(rWFromFile(filename, "rb"), 1)
-
-proc playChannel(channel: cint, chunk: PChunk, loops: cint): cint = 
-  result = playChannelTimed(channel, chunk, loops, - 1)
-
-proc fadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint = 
-  result = fadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
diff --git a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim b/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim
deleted file mode 100644
index 670cf1643..000000000
--- a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim
+++ /dev/null
@@ -1,357 +0,0 @@
-#******************************************************************************
-# Copy of SDL_Mixer without smpeg dependency and mp3 support                    
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    MixerLibName = "SDL_mixer.dll"
-elif defined(macosx): 
-  const 
-    MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else: 
-  const 
-    MixerLibName = "libSDL_mixer.so"
-const 
-  MAJOR_VERSION* = 1
-  MINOR_VERSION* = 2
-  PATCHLEVEL* = 7    # Backwards compatibility
-   
-  CHANNELS* = 8           # Good default values for a PC soundcard 
-  DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32): 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16LSB
-else: 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16MSB
-const 
-  DEFAULT_CHANNELS* = 2
-  MAX_VOLUME* = 128       # Volume of a chunk 
-  PATH_MAX* = 255
-  
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr MusicCMD
-  MusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr WAVStream
-  WAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: pointer
-    start*: int32
-    stop*: int32
-    cvt*: TAudioCVT
-
-  PMidiEvent* = ptr MidiEvent
-  MidiEvent*{.final.} = object 
-    time*: int32
-    channel*: byte
-    typ*: byte
-    a*: byte
-    b*: byte
-
-  PMidiSong* = ptr MidiSong
-  MidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr OGG_Music
-  OGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: cint
-    volume*: cint              #vf: OggVorbis_File;
-    section*: cint
-    cvt*: TAudioCVT
-    lenAvailable*: cint
-    sndAvailable*: pointer
-
-  ErrorEnum* = enum 
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, 
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, 
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, 
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, 
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, 
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, 
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, 
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, 
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, 
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, 
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, 
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, 
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, 
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, 
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, 
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, 
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, 
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, 
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr MODULE
-  MODULE*{.final.} = object 
-  PUNIMOD* = ptr UNIMOD
-  UNIMOD* = MODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk 
-  PChunk* = ptr Chunk
-  Chunk*{.final.} = object 
-    allocated*: cint
-    abuf*: pointer
-    alen*: uint32
-    volume*: byte            # Per-sample volume, 0-128 
-  
-  Fading* = enum 
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  MusicType* = enum 
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
-  PMusic* = ptr Music
-  Music*{.final.} = object 
-    typ*: MusicType
-
-  MixFunction* = proc (udata, stream: pointer, length: cint): pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library. 
-{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent,
-              TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum,
-              TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading, 
-              TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].}
-
-
-proc version*(x: var sdl.Version)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro. 
-proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version", 
-                                      dynlib: MixerLibName.}
-  # Open the mixer with a certain audio format 
-proc openAudio*(frequency: cint, format: uint16, channels: cint, 
-                    chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio", 
-    dynlib: MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  # 
-proc allocateChannels*(numchannels: cint): cint{.cdecl, 
-    importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  # 
-proc querySpec*(frequency: var cint, format: var uint16, channels: var cint): cint{.
-    cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file 
-proc LoadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl, 
-    importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
-proc loadWAV*(filename: cstring): PChunk
-proc loadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS", 
-    dynlib: MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer 
-proc quickLoadWAV*(mem: pointer): PChunk{.cdecl, 
-    importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
-  # Free an audio chunk previously loaded 
-proc freeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk", 
-                                        dynlib: MixerLibName.}
-proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", 
-                                        dynlib: MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc getMusicType*(music: PMusic): MusicType{.cdecl, 
-    importc: "Mix_GetMusicType", dynlib: MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc setPostMix*(mixfunc: MixFunction, arg: pointer){.cdecl, 
-    importc: "Mix_SetPostMix", dynlib: MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  # 
-proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl, 
-    importc: "Mix_HookMusic", dynlib: MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  # 
-proc hookMusicFinished*(musicFinished: pointer){.cdecl, 
-    importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
-  # Get a pointer to the user data for the current music hook 
-proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData", 
-                                       dynlib: MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type 
-  ChannelFinished* = proc (channel: cint){.cdecl.}
-{.deprecated: [TChannelFinished: ChannelFinished].}
-
-proc channelFinished*(channelFinished: ChannelFinished){.cdecl, 
-    importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
-const 
-  CHANNEL_POST* = - 2 
-  
-type 
-  TEffectFunc* = proc (chan: cint, stream: pointer, length: cint, 
-                           udata: pointer): pointer{.cdecl.} 
-  TEffectDone* = proc (chan: cint, udata: pointer): pointer{.cdecl.} 
-
-proc registerEffect*(chan: cint, f: TEffectFunc, d: TEffectDone, 
-                         arg: pointer): cint{.cdecl, 
-    importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
-
-proc unregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl, 
-    importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
-
-proc unregisterAllEffects*(channel: cint): cint{.cdecl, 
-    importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
-
-const 
-  EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"  
-  
-proc setPanning*(channel: cint, left: byte, right: byte): cint{.cdecl, 
-    importc: "Mix_SetPanning", dynlib: MixerLibName.}
-   
-proc setPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetPosition", dynlib: MixerLibName.}
-   
-proc setDistance*(channel: cint, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetDistance", dynlib: MixerLibName.}
-
-proc setReverseStereo*(channel: cint, flip: cint): cint{.cdecl, 
-    importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
-
-proc reserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels", 
-    dynlib: MixerLibName.}
-
-proc groupChannel*(which: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannel", dynlib: MixerLibName.}
-  # Assign several consecutive channels to a group 
-proc groupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannels", dynlib: MixerLibName.}
-  # Finds the first available channel in a group of channels 
-proc groupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable", 
-    dynlib: MixerLibName.}
-  # Returns the number of channels in a group. This is also a subtle
-  #   way to get the total number of channels when 'tag' is -1
-  # 
-proc groupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount", 
-                                     dynlib: MixerLibName.}
-  # Finds the "oldest" sample playing in a group of channels 
-proc groupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest", 
-                                      dynlib: MixerLibName.}
-  # Finds the "most recent" (i.e. last) sample playing in a group of channels 
-proc groupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer", 
-                                     dynlib: MixerLibName.}
-  # The same as above, but the sound is played at most 'ticks' milliseconds 
-proc playChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                           ticks: cint): cint{.cdecl, 
-    importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
-
-proc playChannel*(channel: cint, chunk: PChunk, loops: cint): cint
-proc playMusic*(music: PMusic, loops: cint): cint{.cdecl, 
-    importc: "Mix_PlayMusic", dynlib: MixerLibName.}
-  # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions 
-proc fadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
-proc fadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                             ms: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
-proc fadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
-  # Set the volume in the range of 0-128 of a specific channel or chunk.
-  #   If the specified channel is -1, set volume for all channels.
-  #   Returns the original volume.
-  #   If the specified volume is -1, just return the current volume.
-  #
-proc volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume", 
-    dynlib: MixerLibName.}
-proc volumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl, 
-    importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
-proc volumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic", 
-    dynlib: MixerLibName.}
-  # Halt playing of a particular channel 
-proc haltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel", 
-    dynlib: MixerLibName.}
-proc haltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup", 
-                                    dynlib: MixerLibName.}
-proc haltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic", 
-                            dynlib: MixerLibName.}
-
-proc expireChannel*(channel: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
-
-proc fadeOutChannel*(which: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
-proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
-proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", 
-                                      dynlib: MixerLibName.}
-  # Query the fading status of a channel 
-proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic", 
-                                      dynlib: MixerLibName.}
-proc fadingChannel*(which: cint): Fading{.cdecl, 
-    importc: "Mix_FadingChannel", dynlib: MixerLibName.}
-  # Pause/Resume a particular channel 
-proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
-proc resume*(channel: cint){.cdecl, importc: "Mix_Resume", 
-                                dynlib: MixerLibName.}
-proc paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused", 
-                                     dynlib: MixerLibName.}
-  # Pause/Resume the music stream 
-proc pauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
-proc resumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
-proc rewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
-proc pausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic", 
-                              dynlib: MixerLibName.}
-  # Set the current position in the music stream.
-  #  This returns 0 if successful, or -1 if it failed or isn't implemented.
-  #  This function is only implemented for MOD music formats (set pattern
-  #  order number) and for OGG music (set position in seconds), at the
-  #  moment.
-  #
-proc setMusicPosition*(position: float64): cint{.cdecl, 
-    importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
-  # Check the status of a specific channel.
-  #   If the specified channel is -1, check all channels.
-  #
-proc playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing", 
-                                      dynlib: MixerLibName.}
-proc playingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic", 
-                               dynlib: MixerLibName.}
-  # Stop music and set external music playback command 
-proc setMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD", 
-    dynlib: MixerLibName.}
-  # Synchro value is set by MikMod from modules while playing 
-proc setSynchroValue*(value: cint): cint{.cdecl, 
-    importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
-proc getSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue", 
-                                  dynlib: MixerLibName.}
-  #
-  #  Get the Mix_Chunk currently associated with a mixer channel
-  #    Returns nil if it's an invalid channel, or there's no chunk associated.
-  #
-proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", 
-    dynlib: MixerLibName.}
-  # Close the mixer, halting all playing audio 
-proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
-  # We'll use SDL for reporting errors 
-
-proc version(x: var Version) = 
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-proc loadWAV(filename: cstring): PChunk = 
-  result = LoadWAV_RW(rWFromFile(filename, "rb"), 1)
-
-proc playChannel(channel: cint, chunk: PChunk, loops: cint): cint = 
-  result = playChannelTimed(channel, chunk, loops, - 1)
-
-proc fadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint = 
-  result = fadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
diff --git a/lib/wrappers/sdl/sdl_net.nim b/lib/wrappers/sdl/sdl_net.nim
deleted file mode 100644
index 5bde607f7..000000000
--- a/lib/wrappers/sdl/sdl_net.nim
+++ /dev/null
@@ -1,428 +0,0 @@
-#******************************************************************************
-#
-#  $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
-#
-#
-#                                                                              
-#       Borland Delphi SDL_Net - A x-platform network library for use with SDL.
-#       Conversion of the Simple DirectMedia Layer Network Headers             
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_net.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas somehere in your search path                                       
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April   09 2001 - DL : Initial Translation                                 
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_net.pas,v $
-#  Revision 1.7  2005/01/01 02:14:21  savage
-#  Updated to v1.2.5
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#
-#
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    NetLibName = "SDL_net.dll"
-elif defined(macosx): 
-  const 
-    NetLibName = "libSDL_net.dylib"
-else: 
-  const 
-    NetLibName = "libSDL_net.so"
-const                         #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
-  MAJOR_VERSION* = 1
-  MINOR_VERSION* = 2
-  PATCHLEVEL* = 5        # SDL_Net.h constants
-                         #* Resolve a host name and port to an IP address in network form.
-                         #   If the function succeeds, it will return 0.
-                         #   If the host couldn't be resolved, the host portion of the returned
-                         #   address will be INADDR_NONE, and the function will return -1.
-                         #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-                         # *
-  INADDR_ANY* = 0x00000000
-  INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
-                            #* UDP network API                                                     *
-                            #***********************************************************************
-                            #* The maximum channels on a a UDP socket *
-  MAX_UDPCHANNELS* = 32   #* The maximum addresses bound to a single UDP socket channel *
-  MAX_UDPADDRESSES* = 4
-
-type  # SDL_net.h types
-      #***********************************************************************
-      #* IPv4 hostname resolution API                                        *
-      #***********************************************************************
-  PIPAddress* = ptr IPAddress
-  IPAddress*{.final.} = object  #* TCP network API                                                     
-    host*: uint32             # 32-bit IPv4 host address */
-    port*: uint16             # 16-bit protocol port */
-  
-  PTCPSocket* = ptr TCPSocket
-  TCPSocket*{.final.} = object  # UDP network API
-    ready*: int
-    channel*: int
-    remoteAddress*: IPAddress
-    localAddress*: IPAddress
-    sflag*: int
-
-  PUDP_Channel* = ptr UDP_Channel
-  UDP_Channel*{.final.} = object 
-    numbound*: int
-    address*: array[0..MAX_UDPADDRESSES - 1, IPAddress]
-
-  PUDPSocket* = ptr UDPSocket
-  UDPSocket*{.final.} = object 
-    ready*: int
-    channel*: int
-    address*: IPAddress
-    binding*: array[0..MAX_UDPCHANNELS - 1, UDP_Channel]
-
-  PUDPpacket* = ptr UDPpacket
-  PPUDPpacket* = ptr PUDPpacket
-  UDPpacket*{.final.} = object  #***********************************************************************
-                                 #* Hooks for checking sockets for available data                       *
-                                 #***********************************************************************
-    channel*: int             #* The src/dst channel of the packet *
-    data*: pointer            #* The packet data *
-    length*: int              #* The length of the packet data *
-    maxlen*: int              #* The size of the data buffer *
-    status*: int              #* packet status after sending *
-    address*: IPAddress       #* The source/dest address of an incoming/outgoing packet *
-  
-  PSocket* = ptr Socket
-  Socket*{.final.} = object 
-    ready*: int
-    channel*: int
-
-  PSocketSet* = ptr SocketSet
-  SocketSet*{.final.} = object  # Any network socket can be safely cast to this socket type *
-    numsockets*: int
-    maxsockets*: int
-    sockets*: PSocket
-
-  PGenericSocket* = ptr GenericSocket
-  GenericSocket*{.final.} = object 
-    ready*: int
-{.deprecated: [TSocket: Socket, TSocketSet: SocketSet, TIPAddress: IpAddress,
-        TTCPSocket: TCPSocket, TUDP_Channel: UDP_Channel, TUDPSocket: UDPSocket,
-        TUDPpacket: UDPpacket, TGenericSocket: GenericSocket].}
-
-proc version*(x: var Version)
-  #* Initialize/Cleanup the network API
-  #   SDL must be initialized before calls to functions in this library,
-  #   because this library uses utility functions from the SDL library.
-  #*
-proc init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}
-proc quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}
-  #* Resolve a host name and port to an IP address in network form.
-  #   If the function succeeds, it will return 0.
-  #   If the host couldn't be resolved, the host portion of the returned
-  #   address will be INADDR_NONE, and the function will return -1.
-  #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-  # *
-proc resolveHost*(address: var IPAddress, host: cstring, port: uint16): int{.
-    cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}
-  #* Resolve an ip address to a host name in canonical form.
-  #   If the ip couldn't be resolved, this function returns NULL,
-  #   otherwise a pointer to a static buffer containing the hostname
-  #   is returned.  Note that this function is not thread-safe.
-  #*
-proc resolveIP*(ip: var IPAddress): cstring{.cdecl, 
-    importc: "SDLNet_ResolveIP", dynlib: NetLibName.}
-  #***********************************************************************
-  #* TCP network API                                                     *
-  #***********************************************************************
-  #* Open a TCP network socket
-  #   If ip.host is INADDR_NONE, this creates a local server socket on the
-  #   given port, otherwise a TCP connection to the remote host and port is
-  #   attempted.  The address passed in should already be swapped to network
-  #   byte order (addresses returned from SDLNet_ResolveHost() are already
-  #   in the correct form).
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc tcpOpen*(ip: var IPAddress): PTCPSocket{.cdecl, 
-    importc: "SDLNet_TCP_Open", dynlib: NetLibName.}
-  #* Accept an incoming connection on the given server socket.
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc tcpAccept*(server: PTCPSocket): PTCPSocket{.cdecl, 
-    importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}
-  #* Get the IP address of the remote system associated with the socket.
-  #   If the socket is a server socket, this function returns NULL.
-  #*
-proc tcpGetPeerAddress*(sock: PTCPSocket): PIPAddress{.cdecl, 
-    importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}
-  #* Send 'len' bytes of 'data' over the non-server socket 'sock'
-  #   This function returns the actual amount of data sent.  If the return value
-  #   is less than the amount of data sent, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc tcpSend*(sock: PTCPSocket, data: pointer, length: int): int{.cdecl, 
-    importc: "SDLNet_TCP_Send", dynlib: NetLibName.}
-  #* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
-  #   and store them in the buffer pointed to by 'data'.
-  #   This function returns the actual amount of data received.  If the return
-  #   value is less than or equal to zero, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc tcpRecv*(sock: PTCPSocket, data: pointer, maxlen: int): int{.cdecl, 
-    importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}
-  #* Close a TCP network socket *
-proc tcpClose*(sock: PTCPSocket){.cdecl, importc: "SDLNet_TCP_Close", 
-                                       dynlib: NetLibName.}
-  #***********************************************************************
-  #* UDP network API                                                     *
-  #***********************************************************************
-  #* Allocate/resize/free a single UDP packet 'size' bytes long.
-  #   The new packet is returned, or NULL if the function ran out of memory.
-  # *
-proc allocPacket*(size: int): PUDPpacket{.cdecl, 
-    importc: "SDLNet_AllocPacket", dynlib: NetLibName.}
-proc resizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl, 
-    importc: "SDLNet_ResizePacket", dynlib: NetLibName.}
-proc freePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket", 
-    dynlib: NetLibName.}
-  #* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
-  #   each 'size' bytes long.
-  #   A pointer to the first packet in the array is returned, or NULL if the
-  #   function ran out of memory.
-  # *
-proc allocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl, 
-    importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}
-proc freePacketV*(packetV: PUDPpacket){.cdecl, 
-    importc: "SDLNet_FreePacketV", dynlib: NetLibName.}
-  #* Open a UDP network socket
-  #   If 'port' is non-zero, the UDP socket is bound to a local port.
-  #   This allows other systems to send to this socket via a known port.
-  #*
-proc udpOpen*(port: uint16): PUDPSocket{.cdecl, importc: "SDLNet_UDP_Open", 
-    dynlib: NetLibName.}
-  #* Bind the address 'address' to the requested channel on the UDP socket.
-  #   If the channel is -1, then the first unbound channel will be bound with
-  #   the given address as it's primary address.
-  #   If the channel is already bound, this new address will be added to the
-  #   list of valid source addresses for packets arriving on the channel.
-  #   If the channel is not already bound, then the address becomes the primary
-  #   address, to which all outbound packets on the channel are sent.
-  #   This function returns the channel which was bound, or -1 on error.
-  #*
-proc udpBind*(sock: PUDPSocket, channel: int, address: var IPAddress): int{.
-    cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}
-  #* Unbind all addresses from the given channel *
-proc udpUnbind*(sock: PUDPSocket, channel: int){.cdecl, 
-    importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}
-  #* Get the primary IP address of the remote system associated with the
-  #   socket and channel.  If the channel is -1, then the primary IP port
-  #   of the UDP socket is returned -- this is only meaningful for sockets
-  #   opened with a specific port.
-  #   If the channel is not bound and not -1, this function returns NULL.
-  # *
-proc udpGetPeerAddress*(sock: PUDPSocket, channel: int): PIPAddress{.cdecl, 
-    importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}
-  #* Send a vector of packets to the the channels specified within the packet.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   Each packet will be updated with the status of the packet after it has
-  #   been sent, -1 if the packet send failed.
-  #   This function returns the number of packets sent.
-  #*
-proc udpSendV*(sock: PUDPSocket, packets: PPUDPpacket, npackets: int): int{.
-    cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}
-  #* Send a single packet to the specified channel.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   The packet will be updated with the status of the packet after it has
-  #   been sent.
-  #   This function returns 1 if the packet was sent, or 0 on error.
-  #*
-proc udpSend*(sock: PUDPSocket, channel: int, packet: PUDPpacket): int{.
-    cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.}
-  #* Receive a vector of pending packets from the UDP socket.
-  #   The returned packets contain the source address and the channel they arrived
-  #   on.  If they did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc udpRecvV*(sock: PUDPSocket, packets: PPUDPpacket): int{.cdecl, 
-    importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}
-  #* Receive a single packet from the UDP socket.
-  #   The returned packet contains the source address and the channel it arrived
-  #   on.  If it did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc udpRecv*(sock: PUDPSocket, packet: PUDPpacket): int{.cdecl, 
-    importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}
-  #* Close a UDP network socket *
-proc udpClose*(sock: PUDPSocket){.cdecl, importc: "SDLNet_UDP_Close", 
-                                       dynlib: NetLibName.}
-  #***********************************************************************
-  #* Hooks for checking sockets for available data                       *
-  #***********************************************************************
-  #* Allocate a socket set for use with SDLNet_CheckSockets()
-  #   This returns a socket set for up to 'maxsockets' sockets, or NULL if
-  #   the function ran out of memory.
-  # *
-proc allocSocketSet*(maxsockets: int): PSocketSet{.cdecl, 
-    importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}
-  #* Add a socket to a set of sockets to be checked for available data *
-proc addSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
-    cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.}
-proc tcpAddSocket*(theSet: PSocketSet, sock: PTCPSocket): int
-proc udpAddSocket*(theSet: PSocketSet, sock: PUDPSocket): int
-  #* Remove a socket from a set of sockets to be checked for available data *
-proc delSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
-    cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.}
-proc tcpDelSocket*(theSet: PSocketSet, sock: PTCPSocket): int
-  # SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-proc udpDelSocket*(theSet: PSocketSet, sock: PUDPSocket): int
-  #SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-  #* This function checks to see if data is available for reading on the
-  #   given set of sockets.  If 'timeout' is 0, it performs a quick poll,
-  #   otherwise the function returns when either data is available for
-  #   reading, or the timeout in milliseconds has elapsed, which ever occurs
-  #   first.  This function returns the number of sockets ready for reading,
-  #   or -1 if there was an error with the select() system call.
-  #*
-proc checkSockets*(theSet: PSocketSet, timeout: int32): int{.cdecl, 
-    importc: "SDLNet_CheckSockets", dynlib: NetLibName.}
-  #* After calling SDLNet_CheckSockets(), you can use this function on a
-  #   socket that was in the socket set, to find out if data is available
-  #   for reading.
-  #*
-proc socketReady*(sock: PGenericSocket): bool
-  #* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
-proc freeSocketSet*(theSet: PSocketSet){.cdecl, 
-    importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.}
-  #***********************************************************************
-  #* Platform-independent data conversion functions                      *
-  #***********************************************************************
-  #* Write a 16/32 bit value to network packet buffer *
-proc write16*(value: uint16, area: pointer){.cdecl, 
-    importc: "SDLNet_Write16", dynlib: NetLibName.}
-proc write32*(value: uint32, area: pointer){.cdecl, 
-    importc: "SDLNet_Write32", dynlib: NetLibName.}
-  #* Read a 16/32 bit value from network packet buffer *
-proc read16*(area: pointer): uint16{.cdecl, importc: "SDLNet_Read16", 
-    dynlib: NetLibName.}
-proc read32*(area: pointer): uint32{.cdecl, importc: "SDLNet_Read32", 
-    dynlib: NetLibName.}
-
-proc version(x: var Version) = 
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-proc tcpAddSocket(theSet: PSocketSet, sock: PTCPSocket): int = 
-  result = addSocket(theSet, cast[PGenericSocket](sock))
-
-proc udpAddSocket(theSet: PSocketSet, sock: PUDPSocket): int = 
-  result = addSocket(theSet, cast[PGenericSocket](sock))
-
-proc tcpDelSocket(theSet: PSocketSet, sock: PTCPSocket): int = 
-  result = delSocket(theSet, cast[PGenericSocket](sock))
-
-proc udpDelSocket(theSet: PSocketSet, sock: PUDPSocket): int = 
-  result = delSocket(theSet, cast[PGenericSocket](sock))
-
-proc socketReady(sock: PGenericSocket): bool = 
-  result = sock != nil and sock.ready == 1
diff --git a/lib/wrappers/sdl/sdl_ttf.nim b/lib/wrappers/sdl/sdl_ttf.nim
deleted file mode 100644
index 06604f96e..000000000
--- a/lib/wrappers/sdl/sdl_ttf.nim
+++ /dev/null
@@ -1,338 +0,0 @@
-#
-#  $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
-#
-#
-#******************************************************************************
-#                                                                              
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer          
-#       Conversion of the Simple DirectMedia Layer Headers                     
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_ttf.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so          
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid        
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_ttf.pas,v $
-#  Revision 1.18  2007/06/01 11:16:33  savage
-#  Added IFDEF UNIX for Workaround.
-#
-#  Revision 1.17  2007/06/01 08:38:21  savage
-#  Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
-#
-#  Revision 1.16  2007/05/29 21:32:14  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.15  2007/05/20 20:32:45  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.14  2006/12/02 00:19:01  savage
-#  Updated to latest version
-#
-#  Revision 1.13  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.12  2005/01/05 01:47:14  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.11  2005/01/04 23:14:57  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.10  2005/01/02 19:07:32  savage
-#  Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
-#
-#  Revision 1.9  2005/01/01 02:15:20  savage
-#  Updated to v2.0.7
-#
-#  Revision 1.8  2004/10/07 21:02:32  savage
-#  Fix for FPC
-#
-#  Revision 1.7  2004/09/30 22:39:50  savage
-#  Added a true type font class which contains a wrap text function.
-#  Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:24  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#  
-#
-#******************************************************************************
-#
-#  Define this to workaround a known bug in some freetype versions.
-#  The error manifests as TTF_RenderGlyph_Solid returning nil (error)
-#  and error message (in SDL_Error) is
-#  "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
-#  See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
-#
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    ttfLibName = "SDL_ttf.dll"
-elif defined(macosx): 
-  const 
-    ttfLibName = "libSDL_ttf-2.0.0.dylib"
-else: 
-  const 
-    ttfLibName = "libSDL_ttf(|-2.0).so(|.1|.0)"
-const 
-  MAJOR_VERSION* = 2
-  MINOR_VERSION* = 0
-  PATCHLEVEL* = 8      # Backwards compatibility
-
-  STYLE_NORMAL* = 0x00000000
-  STYLE_BOLD* = 0x00000001
-  STYLE_ITALIC* = 0x00000002
-  STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
-  UNICODE_BOM_NATIVE* = 0x0000FEFF
-  UNICODE_BOM_SWAPPED* = 0x0000FFFE
-
-type 
-  PFont* = ptr Font
-  Font = object  
-{.deprecated: [TFont: Font].}
-  
-  
-# This macro can be used to fill a version structure with the compile-time
-# version of the SDL_ttf library. 
-
-proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version", 
-                                      dynlib: ttfLibName.}
-  # This function tells the library whether UNICODE text is generally
-  #   byteswapped.  A UNICODE BOM character in a string will override
-  #   this setting for the remainder of that string.
-  #
-proc byteSwappedUNICODE*(swapped: cint){.cdecl, 
-    importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
-  #returns 0 on succes, -1 if error occurs
-proc init*(): cint{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
-  #
-  # Open a font file and create a font of the specified point size.
-  # Some .fon fonts will have several sizes embedded in the file, so the
-  # point size becomes the index of choosing which size.  If the value
-  # is too high, the last indexed size will be the default.
-  #
-proc openFont*(filename: cstring, ptsize: cint): PFont{.cdecl, 
-    importc: "TTF_OpenFont", dynlib: ttfLibName.}
-proc openFontIndex*(filename: cstring, ptsize: cint, index: int32): PFont{.
-    cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
-proc openFontRW*(src: PRWops, freesrc: cint, ptsize: cint): PFont{.cdecl, 
-    importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
-proc openFontIndexRW*(src: PRWops, freesrc: cint, ptsize: cint, index: int32): PFont{.
-    cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
-proc getFontStyle*(font: PFont): cint{.cdecl, 
-    importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
-proc setFontStyle*(font: PFont, style: cint){.cdecl, 
-    importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
-  # Get the total height of the font - usually equal to point size 
-proc fontHeight*(font: PFont): cint{.cdecl, importc: "TTF_FontHeight", 
-    dynlib: ttfLibName.}
-  # Get the offset from the baseline to the top of the font
-  #   This is a positive value, relative to the baseline.
-  #
-proc fontAscent*(font: PFont): cint{.cdecl, importc: "TTF_FontAscent", 
-    dynlib: ttfLibName.}
-  # Get the offset from the baseline to the bottom of the font
-  #   This is a negative value, relative to the baseline.
-  #
-proc fontDescent*(font: PFont): cint{.cdecl, importc: "TTF_FontDescent", 
-    dynlib: ttfLibName.}
-  # Get the recommended spacing between lines of text for this font 
-proc fontLineSkip*(font: PFont): cint{.cdecl, 
-    importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
-  # Get the number of faces of the font 
-proc fontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces", 
-    dynlib: ttfLibName.}
-  # Get the font face attributes, if any 
-proc fontFaceIsFixedWidth*(font: PFont): cint{.cdecl, 
-    importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
-proc fontFaceFamilyName*(font: PFont): cstring{.cdecl, 
-    importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
-proc fontFaceStyleName*(font: PFont): cstring{.cdecl, 
-    importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
-  # Get the metrics (dimensions) of a glyph 
-proc glyphMetrics*(font: PFont, ch: uint16, minx: var cint, 
-                       maxx: var cint, miny: var cint, maxy: var cint, 
-                       advance: var cint): cint{.cdecl, 
-    importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
-  # Get the dimensions of a rendered string of text 
-proc sizeText*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
-proc sizeUTF8*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
-proc sizeUNICODE*(font: PFont, text: PUInt16, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderUTF8Solid*(font: PFont, text: cstring, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
-proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
-  #
-  #Create an 8-bit palettized surface and render the given glyph at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.  The glyph is rendered without any padding or
-  #   centering in the X direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderGlyphSolid*(font: PFont, ch: uint16, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderTextShaded*(font: PFont, text: cstring, fg: Color, 
-                            bg: Color): PSurface{.cdecl, 
-    importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
-proc renderUTF8Shaded*(font: PFont, text: cstring, fg: Color, 
-                            bg: Color): PSurface{.cdecl, 
-    importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
-proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: Color, 
-                               bg: Color): PSurface{.cdecl, 
-    importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given glyph at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderGlyphShaded*(font: PFont, ch: uint16, fg: Color, bg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
-  # Create a 32-bit ARGB surface and render the given text at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderTextBlended*(font: PFont, text: cstring, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
-proc renderUTF8Blended*(font: PFont, text: cstring, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
-proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
-  # Create a 32-bit ARGB surface and render the given glyph at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc renderGlyphBlended*(font: PFont, ch: uint16, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
-  # For compatibility with previous versions, here are the old functions 
-  # #define TTF_RenderText(font, text, fg, bg)
-  #	TTF_RenderText_Shaded(font, text, fg, bg)
-  # #define TTF_RenderUTF8(font, text, fg, bg)
-  #	TTF_RenderUTF8_Shaded(font, text, fg, bg)
-  # #define TTF_RenderUNICODE(font, text, fg, bg)
-  #	TTF_RenderUNICODE_Shaded(font, text, fg, bg)
-  # Close an opened font file
-proc closeFont*(font: PFont){.cdecl, importc: "TTF_CloseFont", 
-                                      dynlib: ttfLibName.}
-  # De-initialize TTF engine
-proc quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
-  # Check if the TTF engine is initialized
-proc wasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
-
-
-proc version*(x: var sdl.Version) = 
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-
-proc renderTextSolid*(font: PFont, text: cstring, fg: Color): PSurface{.
-    cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
diff --git a/lib/wrappers/sdl/smpeg.nim b/lib/wrappers/sdl/smpeg.nim
deleted file mode 100644
index 57c16fa47..000000000
--- a/lib/wrappers/sdl/smpeg.nim
+++ /dev/null
@@ -1,335 +0,0 @@
-#******************************************************************************
-#
-#  $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
-#  
-#
-#                                                                              
-#       Borland Delphi SMPEG - SDL MPEG Player Library                         
-#       Conversion of the SMPEG - SDL MPEG Player Library                      
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : smpeg.h                                             
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL-1.2.so.0    
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   May      08 2001 - MT : Initial conversion                                 
-#                                                                              
-#   October  12 2001 - DA : Various changes as suggested by David Acklam       
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                          Fixed all invalid calls to DLL.                     
-#                          Changed constant names to:                          
-#                          const                                               
-#                          STATUS_SMPEG_ERROR = -1;                            
-#                          STATUS_SMPEG_STOPPED = 0;                           
-#                          STATUS_SMPEG_PLAYING = 1;                           
-#                          because SMPEG_ERROR is a function (_SMPEG_error     
-#                          isn't correct), and cannot be two elements with the 
-#                          same name                                           
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: smpeg.pas,v $
-#  Revision 1.7  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.6  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.5  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.4  2004/04/02 10:40:55  savage
-#  Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.3  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#  
-#
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows): 
-  const 
-    SmpegLibName = "smpeg.dll"
-elif defined(macosx): 
-  const 
-    SmpegLibName = "libsmpeg.dylib"
-else: 
-  const 
-    SmpegLibName = "libsmpeg.so"
-const 
-  FILTER_INFO_MB_ERROR* = 1
-  FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG 
-
-type 
-  FilterInfo*{.final.} = object 
-    yuvMbSquareError*: PUInt16
-    yuvPixelSquareError*: PUInt16
-
-  PFilterInfo* = ptr FilterInfo # MPEG filter definition 
-  PFilter* = ptr Filter # Callback functions for the filter 
-  FilterCallback* = proc (dest, source: POverlay, region: PRect, 
-                                 filterInfo: PFilterInfo, data: pointer): pointer{.
-      cdecl.}
-  FilterDestroy* = proc (filter: PFilter): pointer{.cdecl.} # The filter definition itself 
-  Filter*{.final.} = object  # The null filter (default). It simply copies the source rectangle to the video overlay. 
-    flags*: uint32
-    data*: pointer
-    callback*: FilterCallback
-    destroy*: FilterDestroy
-{.deprecated: [TFilterInfo: FilterInfo, TFilterCallback: FilterCallback,
-              TFilterDestroy: FilterDestroy, TFilter: Filter].}
-
-proc filterNull*(): PFilter{.cdecl, importc: "SMPEGfilter_null", 
-    dynlib: SmpegLibName.}
-  # The bilinear filter. A basic low-pass filter that will produce a smoother image. 
-proc filterBilinear*(): PFilter{.cdecl, 
-    importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.}
-  # The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness 
-proc filterDeblocking*(): PFilter{.cdecl, 
-    importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.}
-  #------------------------------------------------------------------------------
-  # SMPEG.h
-  #------------------------------------------------------------------------------
-const 
-  MAJOR_VERSION* = 0
-  MINOR_VERSION* = 4
-  PATCHLEVEL* = 2
-
-type
-  TVersion* = object
-    major*: byte
-    minor*: byte
-    patch*: byte
-
-  Pversion* = ptr TVersion # This is the actual SMPEG object
-  TSMPEG* = object 
-  PSMPEG* = ptr TSMPEG        # Used to get information about the SMPEG object 
-  Info* = object 
-    hasAudio*: int32
-    hasVideo*: int32
-    width*: int32
-    height*: int32
-    currentFrame*: int32
-    currentFps*: float64
-    audioString*: array[0..79, char]
-    audioCurrentFrame*: int32
-    currentOffset*: uint32
-    totalSize*: uint32
-    currentTime*: float64
-    totalTime*: float64
-
-  PInfo* = ptr Info # Possible MPEG status codes 
-{.deprecated: [TInfo: Info].}
-
-const 
-  STATUS_ERROR* = - 1
-  STATUS_STOPPED* = 0
-  STATUS_PLAYING* = 1
-
-type 
-  Status* = int32
-  Pstatus* = ptr int32     # Matches the declaration of SDL_UpdateRect() 
-  TDisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): pointer{.
-      cdecl.} # Create a new SMPEG object from an MPEG file.
-              #  On return, if 'info' is not NULL, it will be filled with information
-              #  about the MPEG object.
-              #  This function returns a new SMPEG object.  Use error() to find out
-              #  whether or not there was a problem building the MPEG stream.
-              #  The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
-              #  subsystem. If not, you will have to use the playaudio() function below
-              #  to extract the decoded data. 
-{.deprecated: [Tstatus: Status].}
-
-proc new*(theFile: cstring, info: PInfo, audio: int): PSMPEG{.cdecl, 
-    importc: "SMPEG_new", dynlib: SmpegLibName.}
-  # The same as above for a file descriptor 
-proc newDescr*(theFile: int, info: PInfo, audio: int): PSMPEG{.
-    cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.}
-  #  The same as above but for a raw chunk of data.  SMPEG makes a copy of the
-  #   data, so the application is free to delete after a successful call to this
-  #   function. 
-proc newData*(data: pointer, size: int, info: PInfo, audio: int): PSMPEG{.
-    cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.}
-  # Get current information about an SMPEG object 
-proc getinfo*(mpeg: PSMPEG, info: PInfo){.cdecl, 
-    importc: "SMPEG_getinfo", dynlib: SmpegLibName.}
-  #procedure getinfo(mpeg: PSMPEG; info: Pointer);
-  #cdecl; external  SmpegLibName;
-  # Enable or disable audio playback in MPEG stream 
-proc enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, 
-    importc: "SMPEG_enableaudio", dynlib: SmpegLibName.}
-  # Enable or disable video playback in MPEG stream 
-proc enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, 
-    importc: "SMPEG_enablevideo", dynlib: SmpegLibName.}
-  # Delete an SMPEG object 
-proc delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete", 
-                                  dynlib: SmpegLibName.}
-  # Get the current status of an SMPEG object 
-proc status*(mpeg: PSMPEG): Status{.cdecl, importc: "SMPEG_status", 
-    dynlib: SmpegLibName.}
-  # status
-  # Set the audio volume of an MPEG stream, in the range 0-100 
-proc setVolume*(mpeg: PSMPEG, volume: int){.cdecl, 
-    importc: "SMPEG_setvolume", dynlib: SmpegLibName.}
-  # Set the destination surface for MPEG video playback
-  #  'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
-  #  'callback' is a function called when an area of 'dst' needs to be updated.
-  #  If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. 
-proc setDisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: PMutex, 
-                       callback: TDisplayCallback){.cdecl, 
-    importc: "SMPEG_setdisplay", dynlib: SmpegLibName.}
-  # Set or clear looping play on an SMPEG object 
-proc loop*(mpeg: PSMPEG, repeat: int){.cdecl, importc: "SMPEG_loop", 
-    dynlib: SmpegLibName.}
-  # Scale pixel display on an SMPEG object 
-proc scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl, 
-    importc: "SMPEG_scaleXY", dynlib: SmpegLibName.}
-proc scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale", 
-    dynlib: SmpegLibName.}
-proc double*(mpeg: PSMPEG, doubleit: bool)
-  # Move the video display area within the destination surface 
-proc move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move", 
-    dynlib: SmpegLibName.}
-  # Set the region of the video to be shown 
-proc setDisplayRegion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl, 
-    importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.}
-  # Play an SMPEG object 
-proc play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play", 
-                                dynlib: SmpegLibName.}
-  # Pause/Resume playback of an SMPEG object
-proc pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause", 
-                                 dynlib: SmpegLibName.}
-  # Stop playback of an SMPEG object 
-proc stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop", 
-                                dynlib: SmpegLibName.}
-  # Rewind the play position of an SMPEG object to the beginning of the MPEG 
-proc rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind", 
-                                  dynlib: SmpegLibName.}
-  # Seek 'bytes' bytes in the MPEG stream 
-proc seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek", 
-    dynlib: SmpegLibName.}
-  # Skip 'seconds' seconds in the MPEG stream 
-proc skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip", 
-    dynlib: SmpegLibName.}
-  # Render a particular frame in the MPEG video
-  #   API CHANGE: This function no longer takes a target surface and position.
-  #               Use setdisplay() and move() to set this information. 
-proc renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl, 
-    importc: "SMPEG_renderFrame", dynlib: SmpegLibName.}
-  # Render the last frame of an MPEG video 
-proc renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl, 
-    importc: "SMPEG_renderFinal", dynlib: SmpegLibName.}
-  # Set video filter 
-proc filter*(mpeg: PSMPEG, filter: PFilter): PFilter{.cdecl, 
-    importc: "SMPEG_filter", dynlib: SmpegLibName.}
-  # Return NULL if there is no error in the MPEG stream, or an error message
-  #   if there was a fatal error in the MPEG stream for the SMPEG object. 
-proc error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error", 
-    dynlib: SmpegLibName.}
-  # Exported callback function for audio playback.
-  #   The function takes a buffer and the amount of data to fill, and returns
-  #   the amount of data in bytes that was actually written.  This will be the
-  #   amount requested unless the MPEG audio has finished.
-  #
-proc playAudio*(mpeg: PSMPEG, stream: pointer, length: int): int{.cdecl, 
-    importc: "SMPEG_playAudio", dynlib: SmpegLibName.}
-  # Wrapper for playAudio() that can be passed to SDL and SDL_mixer 
-proc playAudioSDL*(mpeg: pointer, stream: pointer, length: int){.cdecl, 
-    importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.}
-  # Get the best SDL audio spec for the audio stream 
-proc wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl, 
-    importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.}
-  # Inform SMPEG of the actual SDL audio spec used for sound playback 
-proc actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl, 
-    importc: "SMPEG_actualSpec", dynlib: SmpegLibName.}
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library. 
-proc getversion*(x: var TVersion) =
-  x.major = MAJOR_VERSION
-  x.minor = MINOR_VERSION
-  x.patch = PATCHLEVEL
-
-proc double(mpeg: PSMPEG, doubleit: bool) = 
-  if doubleit: scale(mpeg, 2)
-  else: scale(mpeg, 1)
diff --git a/lib/wrappers/sphinx.nim b/lib/wrappers/sphinx.nim
deleted file mode 100644
index d9e98faa8..000000000
--- a/lib/wrappers/sphinx.nim
+++ /dev/null
@@ -1,263 +0,0 @@
-#
-# $Id: sphinxclient.h 2654 2011-01-31 01:20:58Z kevg $
-#
-#
-# Copyright (c) 2001-2011, Andrew Aksyonoff
-# Copyright (c) 2008-2011, Sphinx Technologies Inc
-# All rights reserved
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Library General Public License. You should
-# have received a copy of the LGPL license along with this program; if you
-# did not, you can find it at http://www.gnu.org/
-#
-
-## Nim wrapper for ``sphinx``.
-
-{.deadCodeElim: on.}
-when defined(windows):
-  const
-    sphinxDll* = "spinx.dll"
-elif defined(macosx):
-  const
-    sphinxDll* = "libspinx.dylib"
-else:
-  const
-    sphinxDll* = "libspinxclient.so"
-
-#/ known searchd status codes:
-const
-  SEARCHD_OK* = 0
-  SEARCHD_ERROR* = 1
-  SEARCHD_RETRY* = 2
-  SEARCHD_WARNING* = 3
-
-#/ known match modes
-
-const
-  SPH_MATCH_ALL* = 0
-  SPH_MATCH_ANY* = 1
-  SPH_MATCH_PHRASE* = 2
-  SPH_MATCH_BOOLEAN* = 3
-  SPH_MATCH_EXTENDED* = 4
-  SPH_MATCH_FULLSCAN* = 5
-  SPH_MATCH_EXTENDED2* = 6
-
-#/ known ranking modes (ext2 only)
-
-const
-  SPH_RANK_PROXIMITY_BM25* = 0
-  SPH_RANK_BM25* = 1
-  SPH_RANK_NONE* = 2
-  SPH_RANK_WORDCOUNT* = 3
-  SPH_RANK_PROXIMITY* = 4
-  SPH_RANK_MATCHANY* = 5
-  SPH_RANK_FIELDMASK* = 6
-  SPH_RANK_SPH04* = 7
-  SPH_RANK_DEFAULT* = SPH_RANK_PROXIMITY_BM25
-
-#/ known sort modes
-
-const
-  SPH_SORT_RELEVANCE* = 0
-  SPH_SORT_ATTR_DESC* = 1
-  SPH_SORT_ATTR_ASC* = 2
-  SPH_SORT_TIME_SEGMENTS* = 3
-  SPH_SORT_EXTENDED* = 4
-  SPH_SORT_EXPR* = 5
-
-#/ known filter types
-
-const
-  SPH_FILTER_VALUES* = 0
-  SPH_FILTER_RANGE* = 1
-  SPH_FILTER_FLOATRANGE* = 2
-
-#/ known attribute types
-
-const
-  SPH_ATTR_INTEGER* = 1
-  SPH_ATTR_TIMESTAMP* = 2
-  SPH_ATTR_ORDINAL* = 3
-  SPH_ATTR_BOOL* = 4
-  SPH_ATTR_FLOAT* = 5
-  SPH_ATTR_BIGINT* = 6
-  SPH_ATTR_STRING* = 7
-  SPH_ATTR_MULTI* = 0x40000000
-
-#/ known grouping functions
-
-const
-  SPH_GROUPBY_DAY* = 0
-  SPH_GROUPBY_WEEK* = 1
-  SPH_GROUPBY_MONTH* = 2
-  SPH_GROUPBY_YEAR* = 3
-  SPH_GROUPBY_ATTR* = 4
-  SPH_GROUPBY_ATTRPAIR* = 5
-
-type
-  SphinxBool* {.size: sizeof(cint).} = enum
-    SPH_FALSE = 0,
-    SPH_TRUE = 1
-
-  Client {.pure, final.} = object
-  PClient* = ptr Client
-  Wordinfo*{.pure, final.} = object
-    word*: cstring
-    docs*: cint
-    hits*: cint
-
-  Result*{.pure, final.} = object
-    error*: cstring
-    warning*: cstring
-    status*: cint
-    num_fields*: cint
-    fields*: cstringArray
-    num_attrs*: cint
-    attr_names*: cstringArray
-    attr_types*: ptr array [0..100_000, cint]
-    num_matches*: cint
-    values_pool*: pointer
-    total*: cint
-    total_found*: cint
-    time_msec*: cint
-    num_words*: cint
-    words*: ptr array [0..100_000, Wordinfo]
-
-  Excerpt_options*{.pure, final.} = object
-    before_match*: cstring
-    after_match*: cstring
-    chunk_separator*: cstring
-    html_strip_mode*: cstring
-    passage_boundary*: cstring
-    limit*: cint
-    limit_passages*: cint
-    limit_words*: cint
-    around*: cint
-    start_passage_id*: cint
-    exact_phrase*: SphinxBool
-    single_passage*: SphinxBool
-    use_boundaries*: SphinxBool
-    weight_order*: SphinxBool
-    query_mode*: SphinxBool
-    force_all_words*: SphinxBool
-    load_files*: SphinxBool
-    allow_empty*: SphinxBool
-    emit_zones*: SphinxBool
-
-  Keyword_info*{.pure, final.} = object
-    tokenized*: cstring
-    normalized*: cstring
-    num_docs*: cint
-    num_hits*: cint
-{.deprecated: [TSphinxBool: SphinxBool,
-              Tclient: Client, Twordinfo: Wordinfo, Tresult: Result,
-              Texcerpt_options: Excerpt_options, Tkeyword_info: Keyword_info].}
-
-proc create*(copy_args: SphinxBool): PClient{.cdecl, importc: "sphinx_create",
-    dynlib: sphinxDll.}
-proc cleanup*(client: PClient){.cdecl, importc: "sphinx_cleanup",
-                                    dynlib: sphinxDll.}
-proc destroy*(client: PClient){.cdecl, importc: "sphinx_destroy",
-                                    dynlib: sphinxDll.}
-proc error*(client: PClient): cstring{.cdecl, importc: "sphinx_error",
-    dynlib: sphinxDll.}
-proc warning*(client: PClient): cstring{.cdecl, importc: "sphinx_warning",
-    dynlib: sphinxDll.}
-proc set_server*(client: PClient, host: cstring, port: cint): SphinxBool{.cdecl,
-    importc: "sphinx_set_server", dynlib: sphinxDll.}
-proc set_connect_timeout*(client: PClient, seconds: float32): SphinxBool{.cdecl,
-    importc: "sphinx_set_connect_timeout", dynlib: sphinxDll.}
-proc open*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_open",
-                                        dynlib: sphinxDll.}
-proc close*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_close",
-    dynlib: sphinxDll.}
-proc set_limits*(client: PClient, offset: cint, limit: cint,
-                 max_matches: cint, cutoff: cint): SphinxBool{.cdecl,
-    importc: "sphinx_set_limits", dynlib: sphinxDll.}
-proc set_max_query_time*(client: PClient, max_query_time: cint): SphinxBool{.
-    cdecl, importc: "sphinx_set_max_query_time", dynlib: sphinxDll.}
-proc set_match_mode*(client: PClient, mode: cint): SphinxBool{.cdecl,
-    importc: "sphinx_set_match_mode", dynlib: sphinxDll.}
-proc set_ranking_mode*(client: PClient, ranker: cint): SphinxBool{.cdecl,
-    importc: "sphinx_set_ranking_mode", dynlib: sphinxDll.}
-proc set_sort_mode*(client: PClient, mode: cint, sortby: cstring): SphinxBool{.
-    cdecl, importc: "sphinx_set_sort_mode", dynlib: sphinxDll.}
-proc set_field_weights*(client: PClient, num_weights: cint,
-                        field_names: cstringArray, field_weights: ptr cint): SphinxBool{.
-    cdecl, importc: "sphinx_set_field_weights", dynlib: sphinxDll.}
-proc set_index_weights*(client: PClient, num_weights: cint,
-                        index_names: cstringArray, index_weights: ptr cint): SphinxBool{.
-    cdecl, importc: "sphinx_set_index_weights", dynlib: sphinxDll.}
-proc set_id_range*(client: PClient, minid: int64, maxid: int64): SphinxBool{.
-    cdecl, importc: "sphinx_set_id_range", dynlib: sphinxDll.}
-proc add_filter*(client: PClient, attr: cstring, num_values: cint,
-                 values: ptr int64, exclude: SphinxBool): SphinxBool{.cdecl,
-    importc: "sphinx_add_filter", dynlib: sphinxDll.}
-proc add_filter_range*(client: PClient, attr: cstring, umin: int64,
-                       umax: int64, exclude: SphinxBool): SphinxBool{.cdecl,
-    importc: "sphinx_add_filter_range", dynlib: sphinxDll.}
-proc add_filter_float_range*(client: PClient, attr: cstring, fmin: float32,
-                             fmax: float32, exclude: SphinxBool): SphinxBool{.cdecl,
-    importc: "sphinx_add_filter_float_range", dynlib: sphinxDll.}
-proc set_geoanchor*(client: PClient, attr_latitude: cstring,
-                    attr_longitude: cstring, latitude: float32, longitude: float32): SphinxBool{.
-    cdecl, importc: "sphinx_set_geoanchor", dynlib: sphinxDll.}
-proc set_groupby*(client: PClient, attr: cstring, groupby_func: cint,
-                  group_sort: cstring): SphinxBool{.cdecl,
-    importc: "sphinx_set_groupby", dynlib: sphinxDll.}
-proc set_groupby_distinct*(client: PClient, attr: cstring): SphinxBool{.cdecl,
-    importc: "sphinx_set_groupby_distinct", dynlib: sphinxDll.}
-proc set_retries*(client: PClient, count: cint, delay: cint): SphinxBool{.cdecl,
-    importc: "sphinx_set_retries", dynlib: sphinxDll.}
-proc add_override*(client: PClient, attr: cstring, docids: ptr int64,
-                   num_values: cint, values: ptr cint): SphinxBool{.cdecl,
-    importc: "sphinx_add_override", dynlib: sphinxDll.}
-proc set_select*(client: PClient, select_list: cstring): SphinxBool{.cdecl,
-    importc: "sphinx_set_select", dynlib: sphinxDll.}
-proc reset_filters*(client: PClient){.cdecl,
-    importc: "sphinx_reset_filters", dynlib: sphinxDll.}
-proc reset_groupby*(client: PClient){.cdecl,
-    importc: "sphinx_reset_groupby", dynlib: sphinxDll.}
-proc query*(client: PClient, query: cstring, index_list: cstring,
-            comment: cstring): ptr Result{.cdecl, importc: "sphinx_query",
-    dynlib: sphinxDll.}
-proc add_query*(client: PClient, query: cstring, index_list: cstring,
-                comment: cstring): cint{.cdecl, importc: "sphinx_add_query",
-    dynlib: sphinxDll.}
-proc run_queries*(client: PClient): ptr Result{.cdecl,
-    importc: "sphinx_run_queries", dynlib: sphinxDll.}
-proc get_num_results*(client: PClient): cint{.cdecl,
-    importc: "sphinx_get_num_results", dynlib: sphinxDll.}
-proc get_id*(result: ptr Result, match: cint): int64{.cdecl,
-    importc: "sphinx_get_id", dynlib: sphinxDll.}
-proc get_weight*(result: ptr Result, match: cint): cint{.cdecl,
-    importc: "sphinx_get_weight", dynlib: sphinxDll.}
-proc get_int*(result: ptr Result, match: cint, attr: cint): int64{.cdecl,
-    importc: "sphinx_get_int", dynlib: sphinxDll.}
-proc get_float*(result: ptr Result, match: cint, attr: cint): float32{.cdecl,
-    importc: "sphinx_get_float", dynlib: sphinxDll.}
-proc get_mva*(result: ptr Result, match: cint, attr: cint): ptr cint{.
-    cdecl, importc: "sphinx_get_mva", dynlib: sphinxDll.}
-proc get_string*(result: ptr Result, match: cint, attr: cint): cstring{.cdecl,
-    importc: "sphinx_get_string", dynlib: sphinxDll.}
-proc init_excerpt_options*(opts: ptr Excerpt_options){.cdecl,
-    importc: "sphinx_init_excerpt_options", dynlib: sphinxDll.}
-proc build_excerpts*(client: PClient, num_docs: cint, docs: cstringArray,
-                     index: cstring, words: cstring, opts: ptr Excerpt_options): cstringArray{.
-    cdecl, importc: "sphinx_build_excerpts", dynlib: sphinxDll.}
-proc update_attributes*(client: PClient, index: cstring, num_attrs: cint,
-                        attrs: cstringArray, num_docs: cint,
-                        docids: ptr int64, values: ptr int64): cint{.
-    cdecl, importc: "sphinx_update_attributes", dynlib: sphinxDll.}
-proc update_attributes_mva*(client: PClient, index: cstring, attr: cstring,
-                            docid: int64, num_values: cint,
-                            values: ptr cint): cint{.cdecl,
-    importc: "sphinx_update_attributes_mva", dynlib: sphinxDll.}
-proc build_keywords*(client: PClient, query: cstring, index: cstring,
-                     hits: SphinxBool, out_num_keywords: ptr cint): ptr Keyword_info{.
-    cdecl, importc: "sphinx_build_keywords", dynlib: sphinxDll.}
-proc status*(client: PClient, num_rows: ptr cint, num_cols: ptr cint): cstringArray{.
-    cdecl, importc: "sphinx_status", dynlib: sphinxDll.}
-proc status_destroy*(status: cstringArray, num_rows: cint, num_cols: cint){.
-    cdecl, importc: "sphinx_status_destroy", dynlib: sphinxDll.}
diff --git a/lib/wrappers/tre.nim b/lib/wrappers/tre.nim
deleted file mode 100644
index 36bf3cb69..000000000
--- a/lib/wrappers/tre.nim
+++ /dev/null
@@ -1,188 +0,0 @@
-#
-#  tre.h - TRE public API definitions
-#
-#  This software is released under a BSD-style license.
-#  See the file LICENSE for details and copyright.
-#
-#
-
-when not defined(treDll):
-  when hostOS == "windows":
-    const treDll = "tre.dll"
-  elif hostOS == "macosx":
-    const treDll = "libtre.dylib"
-  else:
-    const treDll = "libtre.so(.5|)"
-
-const 
-  APPROX* = 1 ## approximate matching functionality
-  MULTIBYTE* = 1 ## multibyte character set support. 
-  VERSION* = "0.8.0" ## TRE version string. 
-  VERSION_1* = 0 ## TRE version level 1. 
-  VERSION_2* = 8 ## TRE version level 2. 
-  VERSION_3* = 0 ## TRE version level 3. 
-
-
-# If the we're not using system regex.h, we need to define the
-#   structs and enums ourselves. 
-
-type 
-  Regoff* = cint
-  Regex*{.pure, final.} = object 
-    re_nsub*: int          ## Number of parenthesized subexpressions. 
-    value*: pointer        ## For internal use only. 
-  
-  Regmatch*{.pure, final.} = object 
-    rm_so*: Regoff
-    rm_eo*: Regoff
-
-  Reg_errcode*{.size: 4.} = enum  ## POSIX tre_regcomp() return error codes. 
-                                   ## (In the order listed in the standard.)	 
-    REG_OK = 0,               ## No error. 
-    REG_NOMATCH,              ## No match. 
-    REG_BADPAT,               ## Invalid regexp. 
-    REG_ECOLLATE,             ## Unknown collating element. 
-    REG_ECTYPE,               ## Unknown character class name. 
-    REG_EESCAPE,              ## Trailing backslash. 
-    REG_ESUBREG,              ## Invalid back reference. 
-    REG_EBRACK,               ## "[]" imbalance 
-    REG_EPAREN,               ## "\(\)" or "()" imbalance 
-    REG_EBRACE,               ## "\{\}" or "{}" imbalance 
-    REG_BADBR,                ## Invalid content of {} 
-    REG_ERANGE,               ## Invalid use of range operator 
-    REG_ESPACE,               ## Out of memory.  
-    REG_BADRPT                ## Invalid use of repetition operators. 
-{.deprecated: [TRegoff: Regoff, TRegex: Regex, TRegmatch: Regmatch,
-              TReg_errcode: Reg_errcode].}
-
-# POSIX tre_regcomp() flags. 
-
-const 
-  REG_EXTENDED* = 1
-  REG_ICASE* = (REG_EXTENDED shl 1)
-  REG_NEWLINE* = (REG_ICASE shl 1)
-  REG_NOSUB* = (REG_NEWLINE shl 1)
-
-# Extra tre_regcomp() flags. 
-
-const 
-  REG_BASIC* = 0
-  REG_LITERAL* = (REG_NOSUB shl 1)
-  REG_RIGHT_ASSOC* = (REG_LITERAL shl 1)
-  REG_UNGREEDY* = (REG_RIGHT_ASSOC shl 1)
-
-# POSIX tre_regexec() flags. 
-
-const 
-  REG_NOTBOL* = 1
-  REG_NOTEOL* = (REG_NOTBOL shl 1)
-
-# Extra tre_regexec() flags. 
-
-const 
-  REG_APPROX_MATCHER* = (REG_NOTEOL shl 1)
-  REG_BACKTRACKING_MATCHER* = (REG_APPROX_MATCHER shl 1)
-
-# The maximum number of iterations in a bound expression. 
-
-const 
-  RE_DUP_MAX* = 255
-
-# The POSIX.2 regexp functions 
-
-proc regcomp*(preg: var Regex, regex: cstring, cflags: cint): cint{.cdecl, 
-    importc: "tre_regcomp", dynlib: treDll.}
-proc regexec*(preg: var Regex, string: cstring, nmatch: int, 
-              pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, 
-    importc: "tre_regexec", dynlib: treDll.}
-proc regerror*(errcode: cint, preg: var Regex, errbuf: cstring, 
-               errbuf_size: int): int{.cdecl, importc: "tre_regerror", 
-    dynlib: treDll.}
-proc regfree*(preg: var Regex){.cdecl, importc: "tre_regfree", dynlib: treDll.}
-# Versions with a maximum length argument and therefore the capability to
-#   handle null characters in the middle of the strings (not in POSIX.2). 
-
-proc regncomp*(preg: var Regex, regex: cstring, len: int, cflags: cint): cint{.
-    cdecl, importc: "tre_regncomp", dynlib: treDll.}
-proc regnexec*(preg: var Regex, string: cstring, len: int, nmatch: int, 
-               pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, 
-    importc: "tre_regnexec", dynlib: treDll.}
-# Approximate matching parameter struct. 
-
-type 
-  TRegaparams*{.pure, final.} = object 
-    cost_ins*: cint           ## Default cost of an inserted character. 
-    cost_del*: cint           ## Default cost of a deleted character. 
-    cost_subst*: cint         ## Default cost of a substituted character. 
-    max_cost*: cint           ## Maximum allowed cost of a match. 
-    max_ins*: cint            ## Maximum allowed number of inserts. 
-    max_del*: cint            ## Maximum allowed number of deletes. 
-    max_subst*: cint          ## Maximum allowed number of substitutes. 
-    max_err*: cint            ## Maximum allowed number of errors total. 
-  
-
-# Approximate matching result struct. 
-
-type 
-  TRegamatch*{.pure, final.} = object 
-    nmatch*: int              ## Length of pmatch[] array. 
-    pmatch*: ptr Regmatch     ## Submatch data. 
-    cost*: cint               ## Cost of the match. 
-    num_ins*: cint            ## Number of inserts in the match. 
-    num_del*: cint            ## Number of deletes in the match. 
-    num_subst*: cint          ## Number of substitutes in the match. 
-  
-
-# Approximate matching functions. 
-
-proc regaexec*(preg: var Regex, string: cstring, match: ptr TRegamatch, 
-               params: TRegaparams, eflags: cint): cint{.cdecl, 
-    importc: "tre_regaexec", dynlib: treDll.}
-proc reganexec*(preg: var Regex, string: cstring, len: int, 
-                match: ptr TRegamatch, params: TRegaparams, 
-                eflags: cint): cint{.
-    cdecl, importc: "tre_reganexec", dynlib: treDll.}
-# Sets the parameters to default values. 
-
-proc regaparams_default*(params: ptr TRegaparams){.cdecl, 
-    importc: "tre_regaparams_default", dynlib: treDll.}
-
-type 
-  TStrSource*{.pure, final.} = object 
-    get_next_char*: proc (c: cstring, pos_add: ptr cint, 
-                          context: pointer): cint{.cdecl.}
-    rewind*: proc (pos: int, context: pointer){.cdecl.}
-    compare*: proc (pos1: int, pos2: int, len: int, context: pointer): cint{.
-        cdecl.}
-    context*: pointer
-
-
-proc reguexec*(preg: var Regex, string: ptr TStrSource, nmatch: int, 
-               pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, 
-    importc: "tre_reguexec", dynlib: treDll.}
-
-proc runtimeVersion*(): cstring{.cdecl, importc: "tre_version", dynlib: treDll.}
-  # Returns the version string.	The returned string is static. 
-
-proc config*(query: cint, result: pointer): cint{.cdecl, importc: "tre_config", 
-    dynlib: treDll.}
-  # Returns the value for a config parameter.  The type to which `result`
-  # must point to depends of the value of `query`, see documentation for
-  # more details. 
-
-const 
-  CONFIG_APPROX* = 0
-  CONFIG_WCHAR* = 1
-  CONFIG_MULTIBYTE* = 2
-  CONFIG_SYSTEM_ABI* = 3
-  CONFIG_VERSION* = 4
-
-# Returns 1 if the compiled pattern has back references, 0 if not. 
-
-proc have_backrefs*(preg: var Regex): cint{.cdecl, 
-    importc: "tre_have_backrefs", dynlib: treDll.}
-# Returns 1 if the compiled pattern uses approximate matching features,
-#   0 if not. 
-
-proc have_approx*(preg: var Regex): cint{.cdecl, importc: "tre_have_approx", 
-    dynlib: treDll.}
diff --git a/lib/wrappers/zip/libzip.nim b/lib/wrappers/zip/libzip.nim
deleted file mode 100644
index 076965d46..000000000
--- a/lib/wrappers/zip/libzip.nim
+++ /dev/null
@@ -1,251 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by
-## Dieter Baron and Thomas Klausner. This version links
-## against ``libzip2.so.2`` unless you define the symbol ``useLibzipSrc``; then
-## it is compiled against some old ``libizp_all.c`` file.
-
-#
-#  zip.h -- exported declarations.
-#  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-#
-#  This file is part of libzip, a library to manipulate ZIP archives.
-#  The authors can be contacted at <libzip@nih.at>
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#  3. The names of the authors may not be used to endorse or promote
-#     products derived from this software without specific prior
-#     written permission.
-# 
-#  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-#  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-#  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-#  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-import times
-
-when defined(unix) and not defined(useLibzipSrc):
-  when defined(macosx):
-    {.pragma: mydll, dynlib: "libzip2.dylib".}
-  else:
-    {.pragma: mydll, dynlib: "libzip(|2).so(|.2|.1|.0)".}
-else:
-  when defined(unix):
-    {.passl: "-lz".}
-  {.compile: "libzip_all.c".}
-  {.pragma: mydll.}
-
-type 
-  ZipSourceCmd* = int32
-
-  ZipSourceCallback* = proc (state: pointer, data: pointer, length: int, 
-                              cmd: ZipSourceCmd): int {.cdecl.}
-  PZipStat* = ptr ZipStat
-  ZipStat* = object           ## the 'zip_stat' struct
-    name*: cstring            ## name of the file  
-    index*: int32             ## index within archive  
-    crc*: int32               ## crc of file data  
-    mtime*: Time              ## modification time  
-    size*: int                ## size of file (uncompressed)  
-    compSize*: int            ## size of file (compressed)  
-    compMethod*: int16        ## compression method used  
-    encryptionMethod*: int16  ## encryption method used  
-  
-  Zip = object
-  ZipSource = object 
-  ZipFile = object
-
-  PZip* = ptr Zip ## represents a zip archive
-  PZipFile* = ptr ZipFile ## represents a file within an archive
-  PZipSource* = ptr ZipSource ## represents a source for an archive
-{.deprecated: [TZipSourceCmd: ZipSourceCmd, TZipStat: ZipStat, TZip: Zip,
-              TZipSourceCallback: ZipSourceCallback, TZipSource: ZipSource,
-              TZipFile: ZipFile].}
-
-# flags for zip_name_locate, zip_fopen, zip_stat, ...  
-const 
-  ZIP_CREATE* = 1'i32
-  ZIP_EXCL* = 2'i32
-  ZIP_CHECKCONS* = 4'i32 
-  ZIP_FL_NOCASE* = 1'i32        ## ignore case on name lookup  
-  ZIP_FL_NODIR* = 2'i32         ## ignore directory component  
-  ZIP_FL_COMPRESSED* = 4'i32    ## read compressed data  
-  ZIP_FL_UNCHANGED* = 8'i32     ## use original data, ignoring changes  
-  ZIP_FL_RECOMPRESS* = 16'i32   ## force recompression of data  
-
-const  # archive global flags flags  
-  ZIP_AFL_TORRENT* = 1'i32      ##  torrent zipped  
-
-const # libzip error codes  
-  ZIP_ER_OK* = 0'i32            ## N No error  
-  ZIP_ER_MULTIDISK* = 1'i32     ## N Multi-disk zip archives not supported  
-  ZIP_ER_RENAME* = 2'i32        ## S Renaming temporary file failed  
-  ZIP_ER_CLOSE* = 3'i32         ## S Closing zip archive failed  
-  ZIP_ER_SEEK* = 4'i32          ## S Seek error  
-  ZIP_ER_READ* = 5'i32          ## S Read error  
-  ZIP_ER_WRITE* = 6'i32         ## S Write error  
-  ZIP_ER_CRC* = 7'i32           ## N CRC error  
-  ZIP_ER_ZIPCLOSED* = 8'i32     ## N Containing zip archive was closed  
-  ZIP_ER_NOENT* = 9'i32         ## N No such file  
-  ZIP_ER_EXISTS* = 10'i32       ## N File already exists  
-  ZIP_ER_OPEN* = 11'i32         ## S Can't open file  
-  ZIP_ER_TMPOPEN* = 12'i32      ## S Failure to create temporary file  
-  ZIP_ER_ZLIB* = 13'i32         ## Z Zlib error  
-  ZIP_ER_MEMORY* = 14'i32       ## N Malloc failure  
-  ZIP_ER_CHANGED* = 15'i32      ## N Entry has been changed  
-  ZIP_ER_COMPNOTSUPP* = 16'i32  ## N Compression method not supported  
-  ZIP_ER_EOF* = 17'i32          ## N Premature EOF  
-  ZIP_ER_INVAL* = 18'i32        ## N Invalid argument  
-  ZIP_ER_NOZIP* = 19'i32        ## N Not a zip archive  
-  ZIP_ER_INTERNAL* = 20'i32     ## N Internal error  
-  ZIP_ER_INCONS* = 21'i32       ## N Zip archive inconsistent  
-  ZIP_ER_REMOVE* = 22'i32       ## S Can't remove file  
-  ZIP_ER_DELETED* = 23'i32      ## N Entry has been deleted  
-   
-const # type of system error value  
-  ZIP_ET_NONE* = 0'i32          ## sys_err unused  
-  ZIP_ET_SYS* = 1'i32           ## sys_err is errno  
-  ZIP_ET_ZLIB* = 2'i32          ## sys_err is zlib error code  
-
-const # compression methods  
-  ZIP_CM_DEFAULT* = -1'i32      ## better of deflate or store  
-  ZIP_CM_STORE* = 0'i32         ## stored (uncompressed)  
-  ZIP_CM_SHRINK* = 1'i32        ## shrunk  
-  ZIP_CM_REDUCE_1* = 2'i32      ## reduced with factor 1  
-  ZIP_CM_REDUCE_2* = 3'i32      ## reduced with factor 2  
-  ZIP_CM_REDUCE_3* = 4'i32      ## reduced with factor 3  
-  ZIP_CM_REDUCE_4* = 5'i32      ## reduced with factor 4  
-  ZIP_CM_IMPLODE* = 6'i32       ## imploded  
-                                ## 7 - Reserved for Tokenizing compression algorithm  
-  ZIP_CM_DEFLATE* = 8'i32       ## deflated  
-  ZIP_CM_DEFLATE64* = 9'i32     ## deflate64  
-  ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding  
-                                  ## 11 - Reserved by PKWARE  
-  ZIP_CM_BZIP2* = 12'i32        ## compressed using BZIP2 algorithm  
-                                ## 13 - Reserved by PKWARE  
-  ZIP_CM_LZMA* = 14'i32         ## LZMA (EFS)  
-                                ## 15-17 - Reserved by PKWARE  
-  ZIP_CM_TERSE* = 18'i32        ## compressed using IBM TERSE (new)  
-  ZIP_CM_LZ77* = 19'i32         ## IBM LZ77 z Architecture (PFS)  
-  ZIP_CM_WAVPACK* = 97'i32      ## WavPack compressed data  
-  ZIP_CM_PPMD* = 98'i32         ## PPMd version I, Rev 1  
-
-const  # encryption methods                              
-  ZIP_EM_NONE* = 0'i32            ## not encrypted  
-  ZIP_EM_TRAD_PKWARE* = 1'i32     ## traditional PKWARE encryption 
-
-const 
-  ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm  
-
-const 
-  ZIP_SOURCE_OPEN* = 0'i32        ## prepare for reading  
-  ZIP_SOURCE_READ* = 1'i32        ## read data  
-  ZIP_SOURCE_CLOSE* = 2'i32       ## reading is done  
-  ZIP_SOURCE_STAT* = 3'i32        ## get meta information  
-  ZIP_SOURCE_ERROR* = 4'i32       ## get error information  
-  constZIP_SOURCE_FREE* = 5'i32   ## cleanup and free resources  
-
-proc zip_add*(para1: PZip, para2: cstring, para3: PZipSource): int32 {.cdecl, 
-    importc: "zip_add", mydll.}
-proc zip_add_dir*(para1: PZip, para2: cstring): int32 {.cdecl,  
-    importc: "zip_add_dir", mydll.}
-proc zip_close*(para1: PZip) {.cdecl, importc: "zip_close", mydll.}
-proc zip_delete*(para1: PZip, para2: int32): int32 {.cdecl, mydll,
-    importc: "zip_delete".}
-proc zip_error_clear*(para1: PZip) {.cdecl, importc: "zip_error_clear", mydll.}
-proc zip_error_get*(para1: PZip, para2: ptr int32, para3: ptr int32) {.cdecl, 
-    importc: "zip_error_get", mydll.}
-proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl, mydll,
-    importc: "zip_error_get_sys_type".}
-proc zip_error_to_str*(para1: cstring, para2: int, para3: int32, 
-                       para4: int32): int32 {.cdecl, mydll,
-    importc: "zip_error_to_str".}
-proc zip_fclose*(para1: PZipFile) {.cdecl, mydll,
-    importc: "zip_fclose".}
-proc zip_file_error_clear*(para1: PZipFile) {.cdecl, mydll,
-    importc: "zip_file_error_clear".}
-proc zip_file_error_get*(para1: PZipFile, para2: ptr int32, para3: ptr int32) {.
-    cdecl, mydll, importc: "zip_file_error_get".}
-proc zip_file_strerror*(para1: PZipFile): cstring {.cdecl, mydll,
-    importc: "zip_file_strerror".}
-proc zip_fopen*(para1: PZip, para2: cstring, para3: int32): PZipFile {.cdecl, 
-    mydll, importc: "zip_fopen".}
-proc zip_fopen_index*(para1: PZip, para2: int32, para3: int32): PZipFile {.
-    cdecl, mydll, importc: "zip_fopen_index".}
-proc zip_fread*(para1: PZipFile, para2: pointer, para3: int): int {.
-    cdecl, mydll, importc: "zip_fread".}
-proc zip_get_archive_comment*(para1: PZip, para2: ptr int32, para3: int32): cstring {.
-    cdecl, mydll, importc: "zip_get_archive_comment".}
-proc zip_get_archive_flag*(para1: PZip, para2: int32, para3: int32): int32 {.
-    cdecl, mydll, importc: "zip_get_archive_flag".}
-proc zip_get_file_comment*(para1: PZip, para2: int32, para3: ptr int32, 
-                           para4: int32): cstring {.cdecl, mydll,
-    importc: "zip_get_file_comment".}
-proc zip_get_name*(para1: PZip, para2: int32, para3: int32): cstring {.cdecl, 
-    mydll, importc: "zip_get_name".}
-proc zip_get_num_files*(para1: PZip): int32 {.cdecl,
-    mydll, importc: "zip_get_num_files".}
-proc zip_name_locate*(para1: PZip, para2: cstring, para3: int32): int32 {.cdecl, 
-    mydll, importc: "zip_name_locate".}
-proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): PZip {.cdecl, 
-    mydll, importc: "zip_open".}
-proc zip_rename*(para1: PZip, para2: int32, para3: cstring): int32 {.cdecl, 
-    mydll, importc: "zip_rename".}
-proc zip_replace*(para1: PZip, para2: int32, para3: PZipSource): int32 {.cdecl, 
-    mydll, importc: "zip_replace".}
-proc zip_set_archive_comment*(para1: PZip, para2: cstring, para3: int32): int32 {.
-    cdecl, mydll, importc: "zip_set_archive_comment".}
-proc zip_set_archive_flag*(para1: PZip, para2: int32, para3: int32): int32 {.
-    cdecl, mydll, importc: "zip_set_archive_flag".}
-proc zip_set_file_comment*(para1: PZip, para2: int32, para3: cstring, 
-                           para4: int32): int32 {.cdecl, mydll,
-    importc: "zip_set_file_comment".}
-proc zip_source_buffer*(para1: PZip, para2: pointer, para3: int, para4: int32): PZipSource {.
-    cdecl, mydll, importc: "zip_source_buffer".}
-proc zip_source_file*(para1: PZip, para2: cstring, para3: int, para4: int): PZipSource {.
-    cdecl, mydll, importc: "zip_source_file".}
-proc zip_source_filep*(para1: PZip, para2: File, para3: int, para4: int): PZipSource {.
-    cdecl, mydll, importc: "zip_source_filep".}
-proc zip_source_free*(para1: PZipSource) {.cdecl, mydll,
-    importc: "zip_source_free".}
-proc zip_source_function*(para1: PZip, para2: ZipSourceCallback, 
-                          para3: pointer): PZipSource {.cdecl, mydll,
-    importc: "zip_source_function".}
-proc zip_source_zip*(para1: PZip, para2: PZip, para3: int32, para4: int32, 
-                     para5: int, para6: int): PZipSource {.cdecl, mydll,
-    importc: "zip_source_zip".}
-proc zip_stat*(para1: PZip, para2: cstring, para3: int32, para4: PZipStat): int32 {.
-    cdecl, mydll, importc: "zip_stat".}
-proc zip_stat_index*(para1: PZip, para2: int32, para3: int32, para4: PZipStat): int32 {.
-    cdecl, mydll, importc: "zip_stat_index".}
-proc zip_stat_init*(para1: PZipStat) {.cdecl, mydll, importc: "zip_stat_init".}
-proc zip_strerror*(para1: PZip): cstring {.cdecl, mydll, importc: "zip_strerror".}
-proc zip_unchange*(para1: PZip, para2: int32): int32 {.cdecl, mydll,
-    importc: "zip_unchange".}
-proc zip_unchange_all*(para1: PZip): int32 {.cdecl, mydll,
-    importc: "zip_unchange_all".}
-proc zip_unchange_archive*(para1: PZip): int32 {.cdecl, mydll,
-    importc: "zip_unchange_archive".}
diff --git a/lib/wrappers/zip/libzip_all.c b/lib/wrappers/zip/libzip_all.c
deleted file mode 100644
index 797374b29..000000000
--- a/lib/wrappers/zip/libzip_all.c
+++ /dev/null
@@ -1,4189 +0,0 @@
-/*
-  zipint.h -- internal declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <zlib.h>
-
-/*
-#ifdef _MSC_VER
-#define ZIP_EXTERN __declspec(dllimport)
-#endif
-*/
-
-/*
-  zip.h -- exported declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#ifndef ZIP_EXTERN
-#define ZIP_EXTERN
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <time.h>
-
-/* flags for zip_open */
-
-#define ZIP_CREATE           1
-#define ZIP_EXCL             2
-#define ZIP_CHECKCONS        4
-
-
-/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
-
-#define ZIP_FL_NOCASE                1 /* ignore case on name lookup */
-#define ZIP_FL_NODIR                2 /* ignore directory component */
-#define ZIP_FL_COMPRESSED        4 /* read compressed data */
-#define ZIP_FL_UNCHANGED        8 /* use original data, ignoring changes */
-#define ZIP_FL_RECOMPRESS      16 /* force recompression of data */
-
-/* archive global flags flags */
-
-#define ZIP_AFL_TORRENT                1 /* torrent zipped */
-
-/* libzip error codes */
-
-#define ZIP_ER_OK             0  /* N No error */
-#define ZIP_ER_MULTIDISK      1  /* N Multi-disk zip archives not supported */
-#define ZIP_ER_RENAME         2  /* S Renaming temporary file failed */
-#define ZIP_ER_CLOSE          3  /* S Closing zip archive failed */
-#define ZIP_ER_SEEK           4  /* S Seek error */
-#define ZIP_ER_READ           5  /* S Read error */
-#define ZIP_ER_WRITE          6  /* S Write error */
-#define ZIP_ER_CRC            7  /* N CRC error */
-#define ZIP_ER_ZIPCLOSED      8  /* N Containing zip archive was closed */
-#define ZIP_ER_NOENT          9  /* N No such file */
-#define ZIP_ER_EXISTS        10  /* N File already exists */
-#define ZIP_ER_OPEN          11  /* S Can't open file */
-#define ZIP_ER_TMPOPEN       12  /* S Failure to create temporary file */
-#define ZIP_ER_ZLIB          13  /* Z Zlib error */
-#define ZIP_ER_MEMORY        14  /* N Malloc failure */
-#define ZIP_ER_CHANGED       15  /* N Entry has been changed */
-#define ZIP_ER_COMPNOTSUPP   16  /* N Compression method not supported */
-#define ZIP_ER_EOF           17  /* N Premature EOF */
-#define ZIP_ER_INVAL         18  /* N Invalid argument */
-#define ZIP_ER_NOZIP         19  /* N Not a zip archive */
-#define ZIP_ER_INTERNAL      20  /* N Internal error */
-#define ZIP_ER_INCONS        21  /* N Zip archive inconsistent */
-#define ZIP_ER_REMOVE        22  /* S Can't remove file */
-#define ZIP_ER_DELETED       23  /* N Entry has been deleted */
-
-
-/* type of system error value */
-
-#define ZIP_ET_NONE              0  /* sys_err unused */
-#define ZIP_ET_SYS              1  /* sys_err is errno */
-#define ZIP_ET_ZLIB              2  /* sys_err is zlib error code */
-
-/* compression methods */
-
-#define ZIP_CM_DEFAULT              -1  /* better of deflate or store */
-#define ZIP_CM_STORE               0  /* stored (uncompressed) */
-#define ZIP_CM_SHRINK               1  /* shrunk */
-#define ZIP_CM_REDUCE_1               2  /* reduced with factor 1 */
-#define ZIP_CM_REDUCE_2               3  /* reduced with factor 2 */
-#define ZIP_CM_REDUCE_3               4  /* reduced with factor 3 */
-#define ZIP_CM_REDUCE_4               5  /* reduced with factor 4 */
-#define ZIP_CM_IMPLODE               6  /* imploded */
-/* 7 - Reserved for Tokenizing compression algorithm */
-#define ZIP_CM_DEFLATE               8  /* deflated */
-#define ZIP_CM_DEFLATE64       9  /* deflate64 */
-#define ZIP_CM_PKWARE_IMPLODE 10  /* PKWARE imploding */
-/* 11 - Reserved by PKWARE */
-#define ZIP_CM_BZIP2          12  /* compressed using BZIP2 algorithm */
-/* 13 - Reserved by PKWARE */
-#define ZIP_CM_LZMA              14  /* LZMA (EFS) */
-/* 15-17 - Reserved by PKWARE */
-#define ZIP_CM_TERSE              18  /* compressed using IBM TERSE (new) */
-#define ZIP_CM_LZ77           19  /* IBM LZ77 z Architecture (PFS) */
-#define ZIP_CM_WAVPACK              97  /* WavPack compressed data */
-#define ZIP_CM_PPMD              98  /* PPMd version I, Rev 1 */
-
-/* encryption methods */
-
-#define ZIP_EM_NONE               0  /* not encrypted */
-#define ZIP_EM_TRAD_PKWARE     1  /* traditional PKWARE encryption */
-#if 0 /* Strong Encryption Header not parsed yet */
-#define ZIP_EM_DES        0x6601  /* strong encryption: DES */
-#define ZIP_EM_RC2_OLD    0x6602  /* strong encryption: RC2, version < 5.2 */
-#define ZIP_EM_3DES_168   0x6603
-#define ZIP_EM_3DES_112   0x6609
-#define ZIP_EM_AES_128    0x660e
-#define ZIP_EM_AES_192    0x660f
-#define ZIP_EM_AES_256    0x6610
-#define ZIP_EM_RC2        0x6702  /* strong encryption: RC2, version >= 5.2 */
-#define ZIP_EM_RC4        0x6801
-#endif
-#define ZIP_EM_UNKNOWN    0xffff  /* unknown algorithm */
-
-typedef long myoff_t; /* XXX: 64 bit support */
-
-enum zip_source_cmd {
-    ZIP_SOURCE_OPEN,        /* prepare for reading */
-    ZIP_SOURCE_READ,         /* read data */
-    ZIP_SOURCE_CLOSE,        /* reading is done */
-    ZIP_SOURCE_STAT,        /* get meta information */
-    ZIP_SOURCE_ERROR,        /* get error information */
-    ZIP_SOURCE_FREE        /* cleanup and free resources */
-};
-
-typedef ssize_t (*zip_source_callback)(void *state, void *data,
-                                       size_t len, enum zip_source_cmd cmd);
-
-struct zip_stat {
-    const char *name;                        /* name of the file */
-    int index;                                /* index within archive */
-    unsigned int crc;                        /* crc of file data */
-    time_t mtime;                        /* modification time */
-    myoff_t size;                                /* size of file (uncompressed) */
-    myoff_t comp_size;                        /* size of file (compressed) */
-    unsigned short comp_method;                /* compression method used */
-    unsigned short encryption_method;        /* encryption method used */
-};
-
-struct zip;
-struct zip_file;
-struct zip_source;
-
-
-ZIP_EXTERN int zip_add(struct zip *, const char *, struct zip_source *);
-ZIP_EXTERN int zip_add_dir(struct zip *, const char *);
-ZIP_EXTERN int zip_close(struct zip *);
-ZIP_EXTERN int zip_delete(struct zip *, int);
-ZIP_EXTERN void zip_error_clear(struct zip *);
-ZIP_EXTERN void zip_error_get(struct zip *, int *, int *);
-ZIP_EXTERN int zip_error_get_sys_type(int);
-ZIP_EXTERN int zip_error_to_str(char *, size_t, int, int);
-ZIP_EXTERN int zip_fclose(struct zip_file *);
-ZIP_EXTERN void zip_file_error_clear(struct zip_file *);
-ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *);
-ZIP_EXTERN const char *zip_file_strerror(struct zip_file *);
-ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, int);
-ZIP_EXTERN struct zip_file *zip_fopen_index(struct zip *, int, int);
-ZIP_EXTERN ssize_t zip_fread(struct zip_file *, void *, size_t);
-ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, int);
-ZIP_EXTERN int zip_get_archive_flag(struct zip *, int, int);
-ZIP_EXTERN const char *zip_get_file_comment(struct zip *, int, int *, int);
-ZIP_EXTERN const char *zip_get_name(struct zip *, int, int);
-ZIP_EXTERN int zip_get_num_files(struct zip *);
-ZIP_EXTERN int zip_name_locate(struct zip *, const char *, int);
-ZIP_EXTERN struct zip *zip_open(const char *, int, int *);
-ZIP_EXTERN int zip_rename(struct zip *, int, const char *);
-ZIP_EXTERN int zip_replace(struct zip *, int, struct zip_source *);
-ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, int);
-ZIP_EXTERN int zip_set_archive_flag(struct zip *, int, int);
-ZIP_EXTERN int zip_set_file_comment(struct zip *, int, const char *, int);
-ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *,
-                                                myoff_t, int);
-ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *,
-                                              myoff_t, myoff_t);
-ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *,
-                                               myoff_t, myoff_t);
-ZIP_EXTERN void zip_source_free(struct zip_source *);
-ZIP_EXTERN struct zip_source *zip_source_function(struct zip *,
-                                                  zip_source_callback, void *);
-ZIP_EXTERN struct zip_source *zip_source_zip(struct zip *, struct zip *,
-                                             int, int, myoff_t, myoff_t);
-ZIP_EXTERN int zip_stat(struct zip *, const char *, int, struct zip_stat *);
-ZIP_EXTERN int zip_stat_index(struct zip *, int, int, struct zip_stat *);
-ZIP_EXTERN void zip_stat_init(struct zip_stat *);
-ZIP_EXTERN const char *zip_strerror(struct zip *);
-ZIP_EXTERN int zip_unchange(struct zip *, int);
-ZIP_EXTERN int zip_unchange_all(struct zip *);
-ZIP_EXTERN int zip_unchange_archive(struct zip *);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
-   */
-/* #undef HAVE_DECL_TZNAME */
-
-#define HAVE_CONFIG_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `fseeko' function. */
-#define HAVE_FSEEKO 1
-
-/* Define to 1 if you have the `ftello' function. */
-#define HAVE_FTELLO 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `z' library (-lz). */
-#define HAVE_LIBZ 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mkstemp' function. */
-#define HAVE_MKSTEMP 1
-
-/* Define to 1 if you have the `MoveFileExA' function. */
-/* #undef HAVE_MOVEFILEEXA */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if `tm_zone' is member of `struct tm'. */
-#define HAVE_STRUCT_TM_TM_ZONE 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
-   `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#define HAVE_TM_ZONE 1
-
-/* Define to 1 if you don't have `tm_zone' but do have the external array
-   `tzname'. */
-/* #undef HAVE_TZNAME */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Name of package */
-#define PACKAGE "libzip"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "libzip@nih.at"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libzip"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libzip 0.9"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libzip"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.9"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-/* #undef TM_IN_SYS_TIME */
-
-/* Version number of package */
-#define VERSION "0.9"
-
-
-#ifndef HAVE_MKSTEMP
-int _zip_mkstemp(char *);
-#define mkstemp _zip_mkstemp
-#endif
-
-#ifdef HAVE_MOVEFILEEXA
-#include <windows.h>
-#define _zip_rename(s, t)                                                \
-        (!MoveFileExA((s), (t),                                                \
-                     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
-#else
-#define _zip_rename        rename
-#endif
-
-#ifndef HAVE_FSEEKO
-#define fseeko(s, o, w)        (fseek((s), (long int)(o), (w)))
-#endif
-#ifndef HAVE_FTELLO
-#define ftello(s)        ((long)ftell((s)))
-#endif
-
-
-#define CENTRAL_MAGIC "PK\1\2"
-#define LOCAL_MAGIC   "PK\3\4"
-#define EOCD_MAGIC    "PK\5\6"
-#define DATADES_MAGIC "PK\7\8"
-#define TORRENT_SIG        "TORRENTZIPPED-"
-#define TORRENT_SIG_LEN        14
-#define TORRENT_CRC_LEN 8
-#define TORRENT_MEM_LEVEL        8
-#define CDENTRYSIZE         46u
-#define LENTRYSIZE          30
-#define MAXCOMLEN        65536
-#define EOCDLEN             22
-#define CDBUFSIZE       (MAXCOMLEN+EOCDLEN)
-#define BUFSIZE                8192
-
-
-/* state of change of a file in zip archive */
-
-enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
-                 ZIP_ST_ADDED, ZIP_ST_RENAMED };
-
-/* constants for struct zip_file's member flags */
-
-#define ZIP_ZF_EOF        1 /* EOF reached */
-#define ZIP_ZF_DECOMP        2 /* decompress data */
-#define ZIP_ZF_CRC        4 /* compute and compare CRC */
-
-/* directory entry: general purpose bit flags */
-
-#define ZIP_GPBF_ENCRYPTED                0x0001        /* is encrypted */
-#define ZIP_GPBF_DATA_DESCRIPTOR        0x0008        /* crc/size after file data */
-#define ZIP_GPBF_STRONG_ENCRYPTION        0x0040  /* uses strong encryption */
-
-/* error information */
-
-struct zip_error {
-    int zip_err;        /* libzip error code (ZIP_ER_*) */
-    int sys_err;        /* copy of errno (E*) or zlib error code */
-    char *str;                /* string representation or NULL */
-};
-
-/* zip archive, part of API */
-
-struct zip {
-    char *zn;                        /* file name */
-    FILE *zp;                        /* file */
-    struct zip_error error;        /* error information */
-
-    unsigned int flags;                /* archive global flags */
-    unsigned int ch_flags;        /* changed archive global flags */
-
-    struct zip_cdir *cdir;        /* central directory */
-    char *ch_comment;                /* changed archive comment */
-    int ch_comment_len;                /* length of changed zip archive
-                                 * comment, -1 if unchanged */
-    int nentry;                        /* number of entries */
-    int nentry_alloc;                /* number of entries allocated */
-    struct zip_entry *entry;        /* entries */
-    int nfile;                        /* number of opened files within archive */
-    int nfile_alloc;                /* number of files allocated */
-    struct zip_file **file;        /* opened files within archive */
-};
-
-/* file in zip archive, part of API */
-
-struct zip_file {
-    struct zip *za;                /* zip archive containing this file */
-    struct zip_error error;        /* error information */
-    int flags;                        /* -1: eof, >0: error */
-
-    int method;                        /* compression method */
-    myoff_t fpos;                        /* position within zip file (fread/fwrite) */
-    unsigned long bytes_left;        /* number of bytes left to read */
-    unsigned long cbytes_left;  /* number of bytes of compressed data left */
-    
-    unsigned long crc;                /* CRC so far */
-    unsigned long crc_orig;        /* CRC recorded in archive */
-    
-    char *buffer;
-    z_stream *zstr;
-};
-
-/* zip archive directory entry (central or local) */
-
-struct zip_dirent {
-    unsigned short version_madeby;        /* (c)  version of creator */
-    unsigned short version_needed;        /* (cl) version needed to extract */
-    unsigned short bitflags;                /* (cl) general purpose bit flag */
-    unsigned short comp_method;                /* (cl) compression method used */
-    time_t last_mod;                        /* (cl) time of last modification */
-    unsigned int crc;                        /* (cl) CRC-32 of uncompressed data */
-    unsigned int comp_size;                /* (cl) size of commpressed data */
-    unsigned int uncomp_size;                /* (cl) size of uncommpressed data */
-    char *filename;                        /* (cl) file name (NUL-terminated) */
-    unsigned short filename_len;        /* (cl) length of filename (w/o NUL) */
-    char *extrafield;                        /* (cl) extra field */
-    unsigned short extrafield_len;        /* (cl) length of extra field */
-    char *comment;                        /* (c)  file comment */
-    unsigned short comment_len;                /* (c)  length of file comment */
-    unsigned short disk_number;                /* (c)  disk number start */
-    unsigned short int_attrib;                /* (c)  internal file attributes */
-    unsigned int ext_attrib;                /* (c)  external file attributes */
-    unsigned int offset;                /* (c)  offset of local header  */
-};
-
-/* zip archive central directory */
-
-struct zip_cdir {
-    struct zip_dirent *entry;        /* directory entries */
-    int nentry;                        /* number of entries */
-
-    unsigned int size;                /* size of central direcotry */
-    unsigned int offset;        /* offset of central directory in file */
-    char *comment;                /* zip archive comment */
-    unsigned short comment_len;        /* length of zip archive comment */
-};
-
-
-
-struct zip_source {
-    zip_source_callback f;
-    void *ud;
-};
-
-/* entry in zip archive directory */
-
-struct zip_entry {
-    enum zip_state state;
-    struct zip_source *source;
-    char *ch_filename;
-    char *ch_comment;
-    int ch_comment_len;
-};
-
-
-
-extern const char * const _zip_err_str[];
-extern const int _zip_nerr_str;
-extern const int _zip_err_type[];
-
-
-
-#define ZIP_ENTRY_DATA_CHANGED(x)        \
-                        ((x)->state == ZIP_ST_REPLACED  \
-                         || (x)->state == ZIP_ST_ADDED)
-
-
-
-int _zip_cdir_compute_crc(struct zip *, uLong *);
-void _zip_cdir_free(struct zip_cdir *);
-struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
-int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
-
-void _zip_dirent_finalize(struct zip_dirent *);
-void _zip_dirent_init(struct zip_dirent *);
-int _zip_dirent_read(struct zip_dirent *, FILE *,
-                     unsigned char **, unsigned int, int, struct zip_error *);
-void _zip_dirent_torrent_normalize(struct zip_dirent *);
-int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
-
-void _zip_entry_free(struct zip_entry *);
-void _zip_entry_init(struct zip *, int);
-struct zip_entry *_zip_entry_new(struct zip *);
-
-void _zip_error_clear(struct zip_error *);
-void _zip_error_copy(struct zip_error *, struct zip_error *);
-void _zip_error_fini(struct zip_error *);
-void _zip_error_get(struct zip_error *, int *, int *);
-void _zip_error_init(struct zip_error *);
-void _zip_error_set(struct zip_error *, int, int);
-const char *_zip_error_strerror(struct zip_error *);
-
-int _zip_file_fillbuf(void *, size_t, struct zip_file *);
-unsigned int _zip_file_get_offset(struct zip *, int);
-
-int _zip_filerange_crc(FILE *, myoff_t, myoff_t, uLong *, struct zip_error *);
-
-struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
-                                         myoff_t, myoff_t);
-
-void _zip_free(struct zip *);
-const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
-int _zip_local_header_read(struct zip *, int);
-void *_zip_memdup(const void *, size_t, struct zip_error *);
-int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
-struct zip *_zip_new(struct zip_error *);
-unsigned short _zip_read2(unsigned char **);
-unsigned int _zip_read4(unsigned char **);
-int _zip_replace(struct zip *, int, const char *, struct zip_source *);
-int _zip_set_name(struct zip *, int, const char *);
-int _zip_unchange(struct zip *, int, int);
-void _zip_unchange_data(struct zip_entry *);
-
-         
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-const char *
-_zip_error_strerror(struct zip_error *err)
-{
-    const char *zs, *ss;
-    char buf[128], *s;
-
-    _zip_error_fini(err);
-
-    if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
-        sprintf(buf, "Unknown error %d", err->zip_err);
-        zs = NULL;
-        ss = buf;
-    }
-    else {
-        zs = _zip_err_str[err->zip_err];
-        
-        switch (_zip_err_type[err->zip_err]) {
-        case ZIP_ET_SYS:
-            ss = strerror(err->sys_err);
-            break;
-
-        case ZIP_ET_ZLIB:
-            ss = zError(err->sys_err);
-            break;
-
-        default:
-            ss = NULL;
-        }
-    }
-
-    if (ss == NULL)
-        return zs;
-    else {
-        if ((s=(char *)malloc(strlen(ss)
-                              + (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
-            return _zip_err_str[ZIP_ER_MEMORY];
-        
-        sprintf(s, "%s%s%s",
-                (zs ? zs : ""),
-                (zs ? ": " : ""),
-                ss);
-        err->str = s;
-
-        return s;
-    }
-}
-
-#include <stdlib.h>
-
-
-
-void
-_zip_error_clear(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-}
-
-
-
-void
-_zip_error_copy(struct zip_error *dst, struct zip_error *src)
-{
-    dst->zip_err = src->zip_err;
-    dst->sys_err = src->sys_err;
-}
-
-
-
-void
-_zip_error_fini(struct zip_error *err)
-{
-    free(err->str);
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_get(struct zip_error *err, int *zep, int *sep)
-{
-    if (zep)
-        *zep = err->zip_err;
-    if (sep) {
-        if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
-            *sep = err->sys_err;
-        else
-            *sep = 0;
-    }
-}
-
-
-
-void
-_zip_error_init(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_set(struct zip_error *err, int ze, int se)
-{
-    if (err) {
-        err->zip_err = ze;
-        err->sys_err = se;
-    }
-}
-
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-
-
-int
-_zip_mkstemp(char *path)
-{
-        int fd;   
-        char *start, *trv;
-        struct stat sbuf;
-        pid_t pid;
-
-        /* To guarantee multiple calls generate unique names even if
-           the file is not created. 676 different possibilities with 7
-           or more X's, 26 with 6 or less. */
-        static char xtra[2] = "aa";
-        int xcnt = 0;
-
-        pid = getpid();
-
-        /* Move to end of path and count trailing X's. */
-        for (trv = path; *trv; ++trv)
-                if (*trv == 'X')
-                        xcnt++;
-                else
-                        xcnt = 0;        
-
-        /* Use at least one from xtra.  Use 2 if more than 6 X's. */
-        if (*(trv - 1) == 'X')
-                *--trv = xtra[0];
-        if (xcnt > 6 && *(trv - 1) == 'X')
-                *--trv = xtra[1];
-
-        /* Set remaining X's to pid digits with 0's to the left. */
-        while (*--trv == 'X') {
-                *trv = (pid % 10) + '0';
-                pid /= 10;
-        }
-
-        /* update xtra for next call. */
-        if (xtra[0] != 'z')
-                xtra[0]++;
-        else {
-                xtra[0] = 'a';
-                if (xtra[1] != 'z')
-                        xtra[1]++;
-                else
-                        xtra[1] = 'a';
-        }
-
-        /*
-         * check the target directory; if you have six X's and it
-         * doesn't exist this runs for a *very* long time.
-         */
-        for (start = trv + 1;; --trv) {
-                if (trv <= path)
-                        break;
-                if (*trv == '/') {
-                        *trv = '\0';
-                        if (stat(path, &sbuf))
-                                return (0);
-                        if (!S_ISDIR(sbuf.st_mode)) {
-                                errno = ENOTDIR;
-                                return (0);
-                        }
-                        *trv = '/';
-                        break;
-                }
-        }
-
-        for (;;) {
-                if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0)
-                        return (fd);
-                if (errno != EEXIST)
-                        return (0);
-
-                /* tricky little algorithm for backward compatibility */
-                for (trv = start;;) {
-                        if (!*trv)
-                                return (0);
-                        if (*trv == 'z')
-                                *trv++ = 'a';
-                        else {
-                                if (isdigit((unsigned char)*trv))
-                                        *trv = 'a';
-                                else
-                                        ++*trv;
-                                break;
-                        }
-                }
-        }
-        /*NOTREACHED*/
-}
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-static time_t _zip_d2u_time(int, int);
-static char *_zip_readfpstr(FILE *, unsigned int, int, struct zip_error *);
-static char *_zip_readstr(unsigned char **, int, int, struct zip_error *);
-static void _zip_u2d_time(time_t, unsigned short *, unsigned short *);
-static void _zip_write2(unsigned short, FILE *);
-static void _zip_write4(unsigned int, FILE *);
-
-
-
-void
-_zip_cdir_free(struct zip_cdir *cd)
-{
-    int i;
-
-    if (!cd)
-        return;
-
-    for (i=0; i<cd->nentry; i++)
-        _zip_dirent_finalize(cd->entry+i);
-    free(cd->comment);
-    free(cd->entry);
-    free(cd);
-}
-
-
-
-struct zip_cdir *
-_zip_cdir_new(int nentry, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    
-    if ((cd=(struct zip_cdir *)malloc(sizeof(*cd))) == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if ((cd->entry=(struct zip_dirent *)malloc(sizeof(*(cd->entry))*nentry))
-        == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        free(cd);
-        return NULL;
-    }
-
-    /* entries must be initialized by caller */
-
-    cd->nentry = nentry;
-    cd->size = cd->offset = 0;
-    cd->comment = NULL;
-    cd->comment_len = 0;
-
-    return cd;
-}
-
-
-
-int
-_zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error)
-{
-    int i;
-
-    cd->offset = ftello(fp);
-
-    for (i=0; i<cd->nentry; i++) {
-        if (_zip_dirent_write(cd->entry+i, fp, 0, error) != 0)
-            return -1;
-    }
-
-    cd->size = ftello(fp) - cd->offset;
-    
-    /* clearerr(fp); */
-    fwrite(EOCD_MAGIC, 1, 4, fp);
-    _zip_write4(0, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write4(cd->size, fp);
-    _zip_write4(cd->offset, fp);
-    _zip_write2(cd->comment_len, fp);
-    fwrite(cd->comment, 1, cd->comment_len, fp);
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-void
-_zip_dirent_finalize(struct zip_dirent *zde)
-{
-    free(zde->filename);
-    zde->filename = NULL;
-    free(zde->extrafield);
-    zde->extrafield = NULL;
-    free(zde->comment);
-    zde->comment = NULL;
-}
-
-
-
-void
-_zip_dirent_init(struct zip_dirent *de)
-{
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 0;
-    de->comp_method = 0;
-    de->last_mod = 0;
-    de->crc = 0;
-    de->comp_size = 0;
-    de->uncomp_size = 0;
-    de->filename = NULL;
-    de->filename_len = 0;
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    de->comment = NULL;
-    de->comment_len = 0;
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-}
-
-
-
-/* _zip_dirent_read(zde, fp, bufp, left, localp, error):
-   Fills the zip directory entry zde.
-
-   If bufp is non-NULL, data is taken from there and bufp is advanced
-   by the amount of data used; no more than left bytes are used.
-   Otherwise data is read from fp as needed.
-
-   If localp != 0, it reads a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_read(struct zip_dirent *zde, FILE *fp,
-                 unsigned char **bufp, unsigned int left, int localp,
-                 struct zip_error *error)
-{
-    unsigned char buf[CDENTRYSIZE];
-    unsigned char *cur;
-    unsigned short dostime, dosdate;
-    unsigned int size;
-
-    if (localp)
-        size = LENTRYSIZE;
-    else
-        size = CDENTRYSIZE;
-    
-    if (bufp) {
-        /* use data from buffer */
-        cur = *bufp;
-        if (left < size) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-    }
-    else {
-        /* read entry from disk */
-        if ((fread(buf, 1, size, fp)<size)) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        left = size;
-        cur = buf;
-    }
-
-    if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return -1;
-    }
-    cur += 4;
-
-    
-    /* convert buffercontents to zip_dirent */
-    
-    if (!localp)
-        zde->version_madeby = _zip_read2(&cur);
-    else
-        zde->version_madeby = 0;
-    zde->version_needed = _zip_read2(&cur);
-    zde->bitflags = _zip_read2(&cur);
-    zde->comp_method = _zip_read2(&cur);
-    
-    /* convert to time_t */
-    dostime = _zip_read2(&cur);
-    dosdate = _zip_read2(&cur);
-    zde->last_mod = _zip_d2u_time(dostime, dosdate);
-    
-    zde->crc = _zip_read4(&cur);
-    zde->comp_size = _zip_read4(&cur);
-    zde->uncomp_size = _zip_read4(&cur);
-    
-    zde->filename_len = _zip_read2(&cur);
-    zde->extrafield_len = _zip_read2(&cur);
-    
-    if (localp) {
-        zde->comment_len = 0;
-        zde->disk_number = 0;
-        zde->int_attrib = 0;
-        zde->ext_attrib = 0;
-        zde->offset = 0;
-    } else {
-        zde->comment_len = _zip_read2(&cur);
-        zde->disk_number = _zip_read2(&cur);
-        zde->int_attrib = _zip_read2(&cur);
-        zde->ext_attrib = _zip_read4(&cur);
-        zde->offset = _zip_read4(&cur);
-    }
-
-    zde->filename = NULL;
-    zde->extrafield = NULL;
-    zde->comment = NULL;
-
-    if (bufp) {
-        if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len
-                                  +zde->comment_len)) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-
-        if (zde->filename_len) {
-            zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readstr(&cur, zde->extrafield_len, 0,
-                                           error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readstr(&cur, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-    else {
-        if (zde->filename_len) {
-            zde->filename = _zip_readfpstr(fp, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readfpstr(fp, zde->extrafield_len, 0,
-                                             error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readfpstr(fp, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-
-    if (bufp)
-      *bufp = cur;
-
-    return 0;
-}
-
-
-
-/* _zip_dirent_torrent_normalize(de);
-   Set values suitable for torrentzip.
-*/
-
-void
-_zip_dirent_torrent_normalize(struct zip_dirent *de)
-{
-    static struct tm torrenttime;
-    static time_t last_mod = 0;
-
-    if (last_mod == 0) {
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time_t now;
-        struct tm *l;
-#endif
-
-        torrenttime.tm_sec = 0;
-        torrenttime.tm_min = 32;
-        torrenttime.tm_hour = 23;
-        torrenttime.tm_mday = 24;
-        torrenttime.tm_mon = 11;
-        torrenttime.tm_year = 96;
-        torrenttime.tm_wday = 0;
-        torrenttime.tm_yday = 0;
-        torrenttime.tm_isdst = 0;
-
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time(&now);
-        l = localtime(&now);
-        torrenttime.tm_gmtoff = l->tm_gmtoff;
-        torrenttime.tm_zone = l->tm_zone;
-#endif
-
-        last_mod = mktime(&torrenttime);
-    }
-    
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 2; /* maximum compression */
-    de->comp_method = ZIP_CM_DEFLATE;
-    de->last_mod = last_mod;
-
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-
-    free(de->extrafield);
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    free(de->comment);
-    de->comment = NULL;
-    de->comment_len = 0;
-}
-
-
-
-/* _zip_dirent_write(zde, fp, localp, error):
-   Writes zip directory entry zde to file fp.
-
-   If localp != 0, it writes a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp,
-                  struct zip_error *error)
-{
-    unsigned short dostime, dosdate;
-
-    fwrite(localp ? LOCAL_MAGIC : CENTRAL_MAGIC, 1, 4, fp);
-
-    if (!localp)
-        _zip_write2(zde->version_madeby, fp);
-    _zip_write2(zde->version_needed, fp);
-    _zip_write2(zde->bitflags, fp);
-    _zip_write2(zde->comp_method, fp);
-
-    _zip_u2d_time(zde->last_mod, &dostime, &dosdate);
-    _zip_write2(dostime, fp);
-    _zip_write2(dosdate, fp);
-    
-    _zip_write4(zde->crc, fp);
-    _zip_write4(zde->comp_size, fp);
-    _zip_write4(zde->uncomp_size, fp);
-    
-    _zip_write2(zde->filename_len, fp);
-    _zip_write2(zde->extrafield_len, fp);
-    
-    if (!localp) {
-        _zip_write2(zde->comment_len, fp);
-        _zip_write2(zde->disk_number, fp);
-        _zip_write2(zde->int_attrib, fp);
-        _zip_write4(zde->ext_attrib, fp);
-        _zip_write4(zde->offset, fp);
-    }
-
-    if (zde->filename_len)
-        fwrite(zde->filename, 1, zde->filename_len, fp);
-
-    if (zde->extrafield_len)
-        fwrite(zde->extrafield, 1, zde->extrafield_len, fp);
-
-    if (!localp) {
-        if (zde->comment_len)
-            fwrite(zde->comment, 1, zde->comment_len, fp);
-    }
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static time_t
-_zip_d2u_time(int dtime, int ddate)
-{
-    struct tm *tm;
-    time_t now;
-
-    now = time(NULL);
-    tm = localtime(&now);
-    /* let mktime decide if DST is in effect */
-    tm->tm_isdst = -1;
-    
-    tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
-    tm->tm_mon = ((ddate>>5)&15) - 1;
-    tm->tm_mday = ddate&31;
-
-    tm->tm_hour = (dtime>>11)&31;
-    tm->tm_min = (dtime>>5)&63;
-    tm->tm_sec = (dtime<<1)&62;
-
-    return mktime(tm);
-}
-
-
-
-unsigned short
-_zip_read2(unsigned char **a)
-{
-    unsigned short ret;
-
-    ret = (*a)[0]+((*a)[1]<<8);
-    *a += 2;
-
-    return ret;
-}
-
-
-
-unsigned int
-_zip_read4(unsigned char **a)
-{
-    unsigned int ret;
-
-    ret = ((((((*a)[3]<<8)+(*a)[2])<<8)+(*a)[1])<<8)+(*a)[0];
-    *a += 4;
-
-    return ret;
-}
-
-
-
-static char *
-_zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if (fread(r, 1, len, fp)<len) {
-        free(r);
-        _zip_error_set(error, ZIP_ER_READ, errno);
-        return NULL;
-    }
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-    
-    return r;
-}
-
-
-
-static char *
-_zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    memcpy(r, *buf, len);
-    *buf += len;
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-
-    return r;
-}
-
-
-
-static void
-_zip_write2(unsigned short i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-
-    return;
-}
-
-
-
-static void
-_zip_write4(unsigned int i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-    putc((i>>16)&0xff, fp);
-    putc((i>>24)&0xff, fp);
-    
-    return;
-}
-
-
-
-static void
-_zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate)
-{
-    struct tm *tm;
-
-    tm = localtime(&time);
-    *ddate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5)
-        + tm->tm_mday;
-    *dtime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5)
-        + ((tm->tm_sec)>>1);
-
-    return;
-}
-
-
-
-ZIP_EXTERN int
-zip_delete(struct zip *za, int idx)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    /* allow duplicate file names, because the file will
-     * be removed directly afterwards */
-    if (_zip_unchange(za, idx, 1) != 0)
-        return -1;
-
-    za->entry[idx].state = ZIP_ST_DELETED;
-
-    return 0;
-}
-
-
-
-ZIP_EXTERN void
-zip_error_clear(struct zip *za)
-{
-    _zip_error_clear(&za->error);
-}
-
-
-ZIP_EXTERN int
-zip_add(struct zip *za, const char *name, struct zip_source *source)
-{
-    if (name == NULL || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-        
-    return _zip_replace(za, -1, name, source);
-}
-
-
-ZIP_EXTERN int
-zip_error_get_sys_type(int ze)
-{
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return 0;
-
-    return _zip_err_type[ze];
-}
-
-
-ZIP_EXTERN void
-zip_error_get(struct zip *za, int *zep, int *sep)
-{
-    _zip_error_get(&za->error, zep, sep);
-}
-
-
-const char * const _zip_err_str[] = {
-    "No error",
-    "Multi-disk zip archives not supported",
-    "Renaming temporary file failed",
-    "Closing zip archive failed",
-    "Seek error",
-    "Read error",
-    "Write error",
-    "CRC error",
-    "Containing zip archive was closed",
-    "No such file",
-    "File already exists",
-    "Can't open file",
-    "Failure to create temporary file",
-    "Zlib error",
-    "Malloc failure",
-    "Entry has been changed",
-    "Compression method not supported",
-    "Premature EOF",
-    "Invalid argument",
-    "Not a zip archive",
-    "Internal error",
-    "Zip archive inconsistent",
-    "Can't remove file",
-    "Entry has been deleted",
-};
-
-const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
-
-#define N ZIP_ET_NONE
-#define S ZIP_ET_SYS
-#define Z ZIP_ET_ZLIB
-
-const int _zip_err_type[] = {
-    N,
-    N,
-    S,
-    S,
-    S,
-    S,
-    S,
-    N,
-    N,
-    N,
-    N,
-    S,
-    S,
-    Z,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    S,
-    N,
-};
-
-
-struct zip_entry *
-_zip_entry_new(struct zip *za)
-{
-    struct zip_entry *ze;
-    if (!za) {
-        ze = (struct zip_entry *)malloc(sizeof(struct zip_entry));
-        if (!ze) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return NULL;
-        }
-    }
-    else {
-        if (za->nentry >= za->nentry_alloc-1) {
-            za->nentry_alloc += 16;
-            za->entry = (struct zip_entry *)realloc(za->entry,
-                                                    sizeof(struct zip_entry)
-                                                    * za->nentry_alloc);
-            if (!za->entry) {
-                _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-                return NULL;
-            }
-        }
-        ze = za->entry+za->nentry;
-    }
-
-    ze->state = ZIP_ST_UNCHANGED;
-
-    ze->ch_filename = NULL;
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-    ze->source = NULL;
-
-    if (za)
-        za->nentry++;
-
-    return ze;
-}
-
-
-void
-_zip_entry_free(struct zip_entry *ze)
-{
-    free(ze->ch_filename);
-    ze->ch_filename = NULL;
-    free(ze->ch_comment);
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-
-    _zip_unchange_data(ze);
-}
-
-
-static int add_data(struct zip *, struct zip_source *, struct zip_dirent *,
-                    FILE *);
-static int add_data_comp(zip_source_callback, void *, struct zip_stat *,
-                         FILE *, struct zip_error *);
-static int add_data_uncomp(struct zip *, zip_source_callback, void *,
-                           struct zip_stat *, FILE *);
-static void ch_set_error(struct zip_error *, zip_source_callback, void *);
-static int copy_data(FILE *, myoff_t, FILE *, struct zip_error *);
-static int write_cdir(struct zip *, struct zip_cdir *, FILE *);
-static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *);
-static int _zip_changed(struct zip *, int *);
-static char *_zip_create_temp_output(struct zip *, FILE **);
-static int _zip_torrentzip_cmp(const void *, const void *);
-
-
-
-struct filelist {
-    int idx;
-    const char *name;
-};
-
-
-
-ZIP_EXTERN int
-zip_close(struct zip *za)
-{
-    int survivors;
-    int i, j, error;
-    char *temp;
-    FILE *out;
-    mode_t mask;
-    struct zip_cdir *cd;
-    struct zip_dirent de;
-    struct filelist *filelist;
-    int reopen_on_error;
-    int new_torrentzip;
-
-    reopen_on_error = 0;
-
-    if (za == NULL)
-        return -1;
-
-    if (!_zip_changed(za, &survivors)) {
-        _zip_free(za);
-        return 0;
-    }
-
-    /* don't create zip files with no entries */
-    if (survivors == 0) {
-        if (za->zn && za->zp) {
-            if (remove(za->zn) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_REMOVE, errno);
-                return -1;
-            }
-        }
-        _zip_free(za);
-        return 0;
-    }               
-
-    if ((filelist=(struct filelist *)malloc(sizeof(filelist[0])*survivors))
-        == NULL)
-        return -1;
-
-    if ((cd=_zip_cdir_new(survivors, &za->error)) == NULL) {
-        free(filelist);
-        return -1;
-    }
-
-    for (i=0; i<survivors; i++)
-        _zip_dirent_init(&cd->entry[i]);
-
-    /* archive comment is special for torrentzip */
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
-        cd->comment = _zip_memdup(TORRENT_SIG "XXXXXXXX",
-                                  TORRENT_SIG_LEN + TORRENT_CRC_LEN,
-                                  &za->error);
-        if (cd->comment == NULL) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-        cd->comment_len = TORRENT_SIG_LEN + TORRENT_CRC_LEN;
-    }
-    else if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, ZIP_FL_UNCHANGED) == 0) {
-        if (_zip_cdir_set_comment(cd, za) == -1) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-    }
-
-    if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
-        _zip_cdir_free(cd);
-        return -1;
-    }
-
-
-    /* create list of files with index into original archive  */
-    for (i=j=0; i<za->nentry; i++) {
-        if (za->entry[i].state == ZIP_ST_DELETED)
-            continue;
-
-        filelist[j].idx = i;
-        filelist[j].name = zip_get_name(za, i, 0);
-        j++;
-    }
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        qsort(filelist, survivors, sizeof(filelist[0]),
-              _zip_torrentzip_cmp);
-
-    new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
-                      && zip_get_archive_flag(za, ZIP_AFL_TORRENT,
-                                              ZIP_FL_UNCHANGED) == 0);
-    error = 0;
-    for (j=0; j<survivors; j++) {
-        i = filelist[j].idx;
-
-        /* create new local directory entry */
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            _zip_dirent_init(&de);
-
-            if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-                _zip_dirent_torrent_normalize(&de);
-                
-            /* use it as central directory entry */
-            memcpy(cd->entry+j, &de, sizeof(cd->entry[j]));
-
-            /* set/update file name */
-            if (za->entry[i].ch_filename == NULL) {
-                if (za->entry[i].state == ZIP_ST_ADDED) {
-                    de.filename = strdup("-");
-                    de.filename_len = 1;
-                    cd->entry[j].filename = "-";
-                }
-                else {
-                    de.filename = strdup(za->cdir->entry[i].filename);
-                    de.filename_len = strlen(de.filename);
-                    cd->entry[j].filename = za->cdir->entry[i].filename;
-                    cd->entry[j].filename_len = de.filename_len;
-                }
-            }
-        }
-        else {
-            /* copy existing directory entries */
-            if (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-                error = 1;
-                break;
-            }
-            if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) {
-                error = 1;
-                break;
-            }
-            if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
-                de.crc = za->cdir->entry[i].crc;
-                de.comp_size = za->cdir->entry[i].comp_size;
-                de.uncomp_size = za->cdir->entry[i].uncomp_size;
-                de.bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
-            }
-            memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j]));
-        }
-
-        if (za->entry[i].ch_filename) {
-            free(de.filename);
-            if ((de.filename=strdup(za->entry[i].ch_filename)) == NULL) {
-                error = 1;
-                break;
-            }
-            de.filename_len = strlen(de.filename);
-            cd->entry[j].filename = za->entry[i].ch_filename;
-            cd->entry[j].filename_len = de.filename_len;
-        }
-
-        if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0
-            && za->entry[i].ch_comment_len != -1) {
-            /* as the rest of cd entries, its malloc/free is done by za */
-            cd->entry[j].comment = za->entry[i].ch_comment;
-            cd->entry[j].comment_len = za->entry[i].ch_comment_len;
-        }
-
-        cd->entry[j].offset = ftello(out);
-
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            struct zip_source *zs;
-
-            zs = NULL;
-            if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) {
-                if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1))
-                    == NULL) {
-                    error = 1;
-                    break;
-                }
-            }
-
-            if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) {
-                error = 1;
-                break;
-            }
-            cd->entry[j].last_mod = de.last_mod;
-            cd->entry[j].comp_method = de.comp_method;
-            cd->entry[j].comp_size = de.comp_size;
-            cd->entry[j].uncomp_size = de.uncomp_size;
-            cd->entry[j].crc = de.crc;
-        }
-        else {
-            if (_zip_dirent_write(&de, out, 1, &za->error) < 0) {
-                error = 1;
-                break;
-            }
-            /* we just read the local dirent, file is at correct position */
-            if (copy_data(za->zp, cd->entry[j].comp_size, out,
-                          &za->error) < 0) {
-                error = 1;
-                break;
-            }
-        }
-
-        _zip_dirent_finalize(&de);
-    }
-
-    if (!error) {
-        if (write_cdir(za, cd, out) < 0)
-            error = 1;
-    }
-   
-    /* pointers in cd entries are owned by za */
-    cd->nentry = 0;
-    _zip_cdir_free(cd);
-
-    if (error) {
-        _zip_dirent_finalize(&de);
-        fclose(out);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-
-    if (fclose(out) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_CLOSE, errno);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-    
-    if (za->zp) {
-        fclose(za->zp);
-        za->zp = NULL;
-        reopen_on_error = 1;
-    }
-    if (_zip_rename(temp, za->zn) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_RENAME, errno);
-        remove(temp);
-        free(temp);
-        if (reopen_on_error) {
-            /* ignore errors, since we're already in an error case */
-            za->zp = fopen(za->zn, "rb");
-        }
-        return -1;
-    }
-    mask = umask(0);
-    umask(mask);
-    chmod(za->zn, 0666&~mask);
-
-    _zip_free(za);
-    free(temp);
-    
-    return 0;
-}
-
-
-
-static int
-add_data(struct zip *za, struct zip_source *zs, struct zip_dirent *de, FILE *ft)
-{
-    myoff_t offstart, offend;
-    zip_source_callback cb;
-    void *ud;
-    struct zip_stat st;
-    
-    cb = zs->f;
-    ud = zs->ud;
-
-    if (cb(ud, &st, sizeof(st), ZIP_SOURCE_STAT) < (ssize_t)sizeof(st)) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_OPEN) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offstart = ftello(ft);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-
-    if (st.comp_method != ZIP_CM_STORE) {
-        if (add_data_comp(cb, ud, &st, ft, &za->error) < 0)
-            return -1;
-    }
-    else {
-        if (add_data_uncomp(za, cb, ud, &st, ft) < 0)
-            return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_CLOSE) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offend = ftello(ft);
-
-    if (fseeko(ft, offstart, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    
-    de->last_mod = st.mtime;
-    de->comp_method = st.comp_method;
-    de->crc = st.crc;
-    de->uncomp_size = st.size;
-    de->comp_size = st.comp_size;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        _zip_dirent_torrent_normalize(de);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-    
-    if (fseeko(ft, offend, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-add_data_comp(zip_source_callback cb, void *ud, struct zip_stat *st,FILE *ft,
-              struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    ssize_t n;
-
-    st->comp_size = 0;
-    while ((n=cb(ud, buf, sizeof(buf), ZIP_SOURCE_READ)) > 0) {
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        st->comp_size += n;
-    }
-    if (n < 0) {
-        ch_set_error(error, cb, ud);
-        return -1;
-    }        
-
-    return 0;
-}
-
-
-
-static int
-add_data_uncomp(struct zip *za, zip_source_callback cb, void *ud,
-                struct zip_stat *st, FILE *ft)
-{
-    char b1[BUFSIZE], b2[BUFSIZE];
-    int end, flush, ret;
-    ssize_t n;
-    size_t n2;
-    z_stream zstr;
-    int mem_level;
-
-    st->comp_method = ZIP_CM_DEFLATE;
-    st->comp_size = st->size = 0;
-    st->crc = crc32(0, NULL, 0);
-
-    zstr.zalloc = Z_NULL;
-    zstr.zfree = Z_NULL;
-    zstr.opaque = NULL;
-    zstr.avail_in = 0;
-    zstr.avail_out = 0;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        mem_level = TORRENT_MEM_LEVEL;
-    else
-        mem_level = MAX_MEM_LEVEL;
-
-    /* -MAX_WBITS: undocumented feature of zlib to _not_ write a zlib header */
-    deflateInit2(&zstr, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, mem_level,
-                 Z_DEFAULT_STRATEGY);
-
-    zstr.next_out = (Bytef *)b2;
-    zstr.avail_out = sizeof(b2);
-    zstr.avail_in = 0;
-
-    flush = 0;
-    end = 0;
-    while (!end) {
-        if (zstr.avail_in == 0 && !flush) {
-            if ((n=cb(ud, b1, sizeof(b1), ZIP_SOURCE_READ)) < 0) {
-                ch_set_error(&za->error, cb, ud);
-                deflateEnd(&zstr);
-                return -1;
-            }
-            if (n > 0) {
-                zstr.avail_in = n;
-                zstr.next_in = (Bytef *)b1;
-                st->size += n;
-                st->crc = crc32(st->crc, (Bytef *)b1, n);
-            }
-            else
-                flush = Z_FINISH;
-        }
-
-        ret = deflate(&zstr, flush);
-        if (ret != Z_OK && ret != Z_STREAM_END) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-        
-        if (zstr.avail_out != sizeof(b2)) {
-            n2 = sizeof(b2) - zstr.avail_out;
-            
-            if (fwrite(b2, 1, n2, ft) != n2) {
-                _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-                return -1;
-            }
-        
-            zstr.next_out = (Bytef *)b2;
-            zstr.avail_out = sizeof(b2);
-            st->comp_size += n2;
-        }
-
-        if (ret == Z_STREAM_END) {
-            deflateEnd(&zstr);
-            end = 1;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static void
-ch_set_error(struct zip_error *error, zip_source_callback cb, void *ud)
-{
-    int e[2];
-
-    if ((cb(ud, e, sizeof(e), ZIP_SOURCE_ERROR)) < (ssize_t)sizeof(e)) {
-        error->zip_err = ZIP_ER_INTERNAL;
-        error->sys_err = 0;
-    }
-    else {
-        error->zip_err = e[0];
-        error->sys_err = e[1];
-    }
-}
-
-
-
-static int
-copy_data(FILE *fs, myoff_t len, FILE *ft, struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    int n, nn;
-
-    if (len == 0)
-        return 0;
-
-    while (len > 0) {
-        nn = len > sizeof(buf) ? sizeof(buf) : len;
-        if ((n=fread(buf, 1, nn, fs)) < 0) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        else if (n == 0) {
-            _zip_error_set(error, ZIP_ER_EOF, 0);
-            return -1;
-        }
-
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        len -= n;
-    }
-
-    return 0;
-}
-
-
-
-static int
-write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out)
-{
-    myoff_t offset;
-    uLong crc;
-    char buf[TORRENT_CRC_LEN+1];
-    
-    if (_zip_cdir_write(cd, out, &za->error) < 0)
-        return -1;
-    
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0)
-        return 0;
-
-
-    /* fix up torrentzip comment */
-
-    offset = ftello(out);
-
-    if (_zip_filerange_crc(out, cd->offset, cd->size, &crc, &za->error) < 0)
-        return -1;
-
-    snprintf(buf, sizeof(buf), "%08lX", (long)crc);
-
-    if (fseeko(out, offset-TORRENT_CRC_LEN, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    if (fwrite(buf, TORRENT_CRC_LEN, 1, out) != 1) {
-        _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src)
-{
-    if (src->ch_comment_len != -1) {
-        dest->comment = _zip_memdup(src->ch_comment,
-                                    src->ch_comment_len, &src->error);
-        if (dest->comment == NULL)
-            return -1;
-        dest->comment_len = src->ch_comment_len;
-    } else {
-        if (src->cdir && src->cdir->comment) {
-            dest->comment = _zip_memdup(src->cdir->comment,
-                                        src->cdir->comment_len, &src->error);
-            if (dest->comment == NULL)
-                return -1;
-            dest->comment_len = src->cdir->comment_len;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_changed(struct zip *za, int *survivorsp)
-{
-    int changed, i, survivors;
-
-    changed = survivors = 0;
-
-    if (za->ch_comment_len != -1
-        || za->ch_flags != za->flags)
-        changed = 1;
-
-    for (i=0; i<za->nentry; i++) {
-        if ((za->entry[i].state != ZIP_ST_UNCHANGED)
-            || (za->entry[i].ch_comment_len != -1))
-            changed = 1;
-        if (za->entry[i].state != ZIP_ST_DELETED)
-            survivors++;
-    }
-
-    *survivorsp = survivors;
-
-    return changed;
-}
-
-
-
-static char *
-_zip_create_temp_output(struct zip *za, FILE **outp)
-{
-    char *temp;
-    int tfd;
-    FILE *tfp;
-    
-    if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    sprintf(temp, "%s.XXXXXX", za->zn);
-
-    if ((tfd=mkstemp(temp)) == -1) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        free(temp);
-        return NULL;
-    }
-    
-    if ((tfp=fdopen(tfd, "r+b")) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        close(tfd);
-        remove(temp);
-        free(temp);
-        return NULL;
-    }
-
-    *outp = tfp;
-    return temp;
-}
-
-
-
-static int
-_zip_torrentzip_cmp(const void *a, const void *b)
-{
-    return strcasecmp(((const struct filelist *)a)->name,
-                      ((const struct filelist *)b)->name);
-}
-
-
-
-ZIP_EXTERN int
-zip_add_dir(struct zip *za, const char *name)
-{
-    int len, ret;
-    char *s;
-    struct zip_source *source;
-
-    if (name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    s = NULL;
-    len = strlen(name);
-
-    if (name[len-1] != '/') {
-        if ((s=(char *)malloc(len+2)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return -1;
-        }
-        strcpy(s, name);
-        s[len] = '/';
-        s[len+1] = '\0';
-    }
-
-    if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
-        free(s);
-        return -1;
-    }
-        
-    ret = _zip_replace(za, -1, s ? s : name, source);
-
-    free(s);
-    if (ret < 0)
-        zip_source_free(source);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_error_to_str(char *buf, size_t len, int ze, int se)
-{
-    const char *zs, *ss;
-
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return snprintf(buf, len, "Unknown error %d", ze);
-
-    zs = _zip_err_str[ze];
-        
-    switch (_zip_err_type[ze]) {
-    case ZIP_ET_SYS:
-        ss = strerror(se);
-        break;
-        
-    case ZIP_ET_ZLIB:
-        ss = zError(se);
-        break;
-        
-    default:
-        ss = NULL;
-    }
-
-    return snprintf(buf, len, "%s%s%s",
-                    zs, (ss ? ": " : ""), (ss ? ss : ""));
-}
-
-
-ZIP_EXTERN void
-zip_file_error_clear(struct zip_file *zf)
-{
-    _zip_error_clear(&zf->error);
-}
-
-
-ZIP_EXTERN int
-zip_fclose(struct zip_file *zf)
-{
-    int i, ret;
-    
-    if (zf->zstr)
-        inflateEnd(zf->zstr);
-    free(zf->buffer);
-    free(zf->zstr);
-
-    for (i=0; i<zf->za->nfile; i++) {
-        if (zf->za->file[i] == zf) {
-            zf->za->file[i] = zf->za->file[zf->za->nfile-1];
-            zf->za->nfile--;
-            break;
-        }
-    }
-
-    ret = 0;
-    if (zf->error.zip_err)
-        ret = zf->error.zip_err;
-    else if ((zf->flags & ZIP_ZF_CRC) && (zf->flags & ZIP_ZF_EOF)) {
-        /* if EOF, compare CRC */
-        if (zf->crc_orig != zf->crc)
-            ret = ZIP_ER_CRC;
-    }
-
-    free(zf);
-    return ret;
-}
-
-
-int
-_zip_filerange_crc(FILE *fp, myoff_t start, myoff_t len, uLong *crcp,
-                   struct zip_error *errp)
-{
-    Bytef buf[BUFSIZE];
-    size_t n;
-
-    *crcp = crc32(0L, Z_NULL, 0);
-
-    if (fseeko(fp, start, SEEK_SET) != 0) {
-        _zip_error_set(errp, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    
-    while (len > 0) {
-        n = len > BUFSIZE ? BUFSIZE : len;
-        if ((n=fread(buf, 1, n, fp)) <= 0) {
-            _zip_error_set(errp, ZIP_ER_READ, errno);
-            return -1;
-        }
-
-        *crcp = crc32(*crcp, buf, n);
-
-        len-= n;
-    }
-
-    return 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_file_strerror(struct zip_file *zf)
-{
-    return _zip_error_strerror(&zf->error);
-}
-
-
-/* _zip_file_get_offset(za, ze):
-   Returns the offset of the file data for entry ze.
-
-   On error, fills in za->error and returns 0.
-*/
-
-unsigned int
-_zip_file_get_offset(struct zip *za, int idx)
-{
-    struct zip_dirent de;
-    unsigned int offset;
-
-    offset = za->cdir->entry[idx].offset;
-
-    if (fseeko(za->zp, offset, SEEK_SET) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return 0;
-    }
-
-    if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0)
-        return 0;
-
-    offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
-
-    _zip_dirent_finalize(&de);
-
-    return offset;
-}
-
-
-ZIP_EXTERN void
-zip_file_error_get(struct zip_file *zf, int *zep, int *sep)
-{
-    _zip_error_get(&zf->error, zep, sep);
-}
-
-
-static struct zip_file *_zip_file_new(struct zip *za);
-
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen_index(struct zip *za, int fileno, int flags)
-{
-    int len, ret;
-    int zfflags;
-    struct zip_file *zf;
-
-    if ((fileno < 0) || (fileno >= za->nentry)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+fileno)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (fileno >= za->cdir->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    zfflags = 0;
-    switch (za->cdir->entry[fileno].comp_method) {
-    case ZIP_CM_STORE:
-        zfflags |= ZIP_ZF_CRC;
-        break;
-
-    case ZIP_CM_DEFLATE:
-        if ((flags & ZIP_FL_COMPRESSED) == 0)
-            zfflags |= ZIP_ZF_CRC | ZIP_ZF_DECOMP;
-        break;
-    default:
-        if ((flags & ZIP_FL_COMPRESSED) == 0) {
-            _zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
-            return NULL;
-        }
-        break;
-    }
-
-    zf = _zip_file_new(za);
-
-    zf->flags = zfflags;
-    /* zf->name = za->cdir->entry[fileno].filename; */
-    zf->method = za->cdir->entry[fileno].comp_method;
-    zf->bytes_left = za->cdir->entry[fileno].uncomp_size;
-    zf->cbytes_left = za->cdir->entry[fileno].comp_size;
-    zf->crc_orig = za->cdir->entry[fileno].crc;
-
-    if ((zf->fpos=_zip_file_get_offset(za, fileno)) == 0) {
-        zip_fclose(zf);
-        return NULL;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0)
-        zf->bytes_left = zf->cbytes_left;
-    else {
-        if ((zf->buffer=(char *)malloc(BUFSIZE)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-
-        len = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-        if (len <= 0) {
-            _zip_error_copy(&za->error, &zf->error);
-            zip_fclose(zf);
-        return NULL;
-        }
-
-        if ((zf->zstr = (z_stream *)malloc(sizeof(z_stream))) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-        zf->zstr->zalloc = Z_NULL;
-        zf->zstr->zfree = Z_NULL;
-        zf->zstr->opaque = NULL;
-        zf->zstr->next_in = (Bytef *)zf->buffer;
-        zf->zstr->avail_in = len;
-        
-        /* negative value to tell zlib that there is no header */
-        if ((ret=inflateInit2(zf->zstr, -MAX_WBITS)) != Z_OK) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            zip_fclose(zf);
-            return NULL;
-        }
-    }
-    
-    return zf;
-}
-
-
-
-int
-_zip_file_fillbuf(void *buf, size_t buflen, struct zip_file *zf)
-{
-    int i, j;
-
-    if (zf->error.zip_err != ZIP_ER_OK)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || zf->cbytes_left <= 0 || buflen <= 0)
-        return 0;
-    
-    if (fseeko(zf->za->zp, zf->fpos, SEEK_SET) < 0) {
-        _zip_error_set(&zf->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    if (buflen < zf->cbytes_left)
-        i = buflen;
-    else
-        i = zf->cbytes_left;
-
-    j = fread(buf, 1, i, zf->za->zp);
-    if (j == 0) {
-        _zip_error_set(&zf->error, ZIP_ER_EOF, 0);
-        j = -1;
-    }
-    else if (j < 0)
-        _zip_error_set(&zf->error, ZIP_ER_READ, errno);
-    else {
-        zf->fpos += j;
-        zf->cbytes_left -= j;
-    }
-
-    return j;        
-}
-
-
-
-static struct zip_file *
-_zip_file_new(struct zip *za)
-{
-    struct zip_file *zf, **file;
-    int n;
-
-    if ((zf=(struct zip_file *)malloc(sizeof(struct zip_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    if (za->nfile >= za->nfile_alloc-1) {
-        n = za->nfile_alloc + 10;
-        file = (struct zip_file **)realloc(za->file,
-                                           n*sizeof(struct zip_file *));
-        if (file == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(zf);
-            return NULL;
-        }
-        za->nfile_alloc = n;
-        za->file = file;
-    }
-
-    za->file[za->nfile++] = zf;
-
-    zf->za = za;
-    _zip_error_init(&zf->error);
-    zf->flags = 0;
-    zf->crc = crc32(0L, Z_NULL, 0);
-    zf->crc_orig = 0;
-    zf->method = -1;
-    zf->bytes_left = zf->cbytes_left = 0;
-    zf->fpos = 0;
-    zf->buffer = NULL;
-    zf->zstr = NULL;
-
-    return zf;
-}
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen(struct zip *za, const char *fname, int flags)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return NULL;
-
-    return zip_fopen_index(za, idx, flags);
-}
-
-
-ZIP_EXTERN int
-zip_set_file_comment(struct zip *za, int idx, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (idx < 0 || idx >= za->nentry
-        || len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = tmpcom;
-    za->entry[idx].ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_file(struct zip *za, const char *fname, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (fname == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, fname, NULL, start, len);
-}
-
-
-struct read_data {
-    const char *buf, *data, *end;
-    time_t mtime;
-    int freep;
-};
-
-static ssize_t read_data(void *state, void *data, size_t len,
-                         enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_buffer(struct zip *za, const void *data, myoff_t len, int freep)
-{
-    struct read_data *f;
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if (len < 0 || (data == NULL && len > 0)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_data *)malloc(sizeof(*f))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->data = (const char *)data;
-    f->end = ((const char *)data)+len;
-    f->freep = freep;
-    f->mtime = time(NULL);
-    
-    if ((zs=zip_source_function(za, read_data, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_data *z;
-    char *buf;
-    size_t n;
-
-    z = (struct read_data *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        z->buf = z->data;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        n = z->end - z->buf;
-        if (n > len)
-            n = len;
-
-        if (n) {
-            memcpy(buf, z->buf, n);
-            z->buf += n;
-        }
-
-        return n;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = z->mtime;
-            st->size = z->end - z->data;
-            
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            e[0] = e[1] = 0;
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        if (z->freep) {
-            free((void *)z->data);
-            z->data = NULL;
-        }
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-int
-_zip_set_name(struct zip *za, int idx, const char *name)
-{
-    char *s;
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry || name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((i=_zip_name_locate(za, name, 0, NULL)) != -1 && i != idx) {
-        _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-        return -1;
-    }
-
-    /* no effective name change */
-    if (i == idx)
-        return 0;
-    
-    if ((s=strdup(name)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return -1;
-    }
-    
-    if (za->entry[idx].state == ZIP_ST_UNCHANGED) 
-        za->entry[idx].state = ZIP_ST_RENAMED;
-
-    free(za->entry[idx].ch_filename);
-    za->entry[idx].ch_filename = s;
-
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_flag(struct zip *za, int flag, int value)
-{
-    if (value)
-        za->ch_flags |= flag;
-    else
-        za->ch_flags &= ~flag;
-
-    return 0;
-}
-
-
-void
-_zip_unchange_data(struct zip_entry *ze)
-{
-    if (ze->source) {
-        (void)ze->source->f(ze->source->ud, NULL, 0, ZIP_SOURCE_FREE);
-        free(ze->source);
-        ze->source = NULL;
-    }
-    
-    ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED;
-}
-
-
-ZIP_EXTERN int
-zip_unchange_archive(struct zip *za)
-{
-    free(za->ch_comment);
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-
-    za->ch_flags = za->flags;
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange(struct zip *za, int idx)
-{
-    return _zip_unchange(za, idx, 0);
-}
-
-
-
-int
-_zip_unchange(struct zip *za, int idx, int allow_duplicates)
-{
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (za->entry[idx].ch_filename) {
-        if (!allow_duplicates) {
-            i = _zip_name_locate(za,
-                         _zip_get_name(za, idx, ZIP_FL_UNCHANGED, NULL),
-                                 0, NULL);
-            if (i != -1 && i != idx) {
-                _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-                return -1;
-            }
-        }
-
-        free(za->entry[idx].ch_filename);
-        za->entry[idx].ch_filename = NULL;
-    }
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = NULL;
-    za->entry[idx].ch_comment_len = -1;
-
-    _zip_unchange_data(za->entry+idx);
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange_all(struct zip *za)
-{
-    int ret, i;
-
-    ret = 0;
-    for (i=0; i<za->nentry; i++)
-        ret |= _zip_unchange(za, i, 1);
-
-    ret |= zip_unchange_archive(za);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_comment(struct zip *za, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->ch_comment);
-    za->ch_comment = tmpcom;
-    za->ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_replace(struct zip *za, int idx, struct zip_source *source)
-{
-    if (idx < 0 || idx >= za->nentry || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (_zip_replace(za, idx, NULL, source) == -1)
-        return -1;
-
-    return 0;
-}
-
-
-
-
-int
-_zip_replace(struct zip *za, int idx, const char *name,
-             struct zip_source *source)
-{
-    if (idx == -1) {
-        if (_zip_entry_new(za) == NULL)
-            return -1;
-
-        idx = za->nentry - 1;
-    }
-    
-    _zip_unchange_data(za->entry+idx);
-
-    if (name && _zip_set_name(za, idx, name) != 0)
-        return -1;
-    
-    za->entry[idx].state = ((za->cdir == NULL || idx >= za->cdir->nentry)
-                            ? ZIP_ST_ADDED : ZIP_ST_REPLACED);
-    za->entry[idx].source = source;
-
-    return idx;
-}
-
-
-ZIP_EXTERN int
-zip_rename(struct zip *za, int idx, const char *name)
-{
-    const char *old_name;
-    int old_is_dir, new_is_dir;
-    
-    if (idx >= za->nentry || idx < 0 || name[0] == '\0') {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((old_name=zip_get_name(za, idx, 0)) == NULL)
-        return -1;
-                                                                    
-    new_is_dir = (name[strlen(name)-1] == '/');
-    old_is_dir = (old_name[strlen(old_name)-1] == '/');
-
-    if (new_is_dir != old_is_dir) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    return _zip_set_name(za, idx, name);
-}
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void set_error(int *, struct zip_error *, int);
-static struct zip *_zip_allocate_new(const char *, int *);
-static int _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *);
-static void _zip_check_torrentzip(struct zip *);
-static struct zip_cdir *_zip_find_central_dir(FILE *, int, int *, myoff_t);
-static int _zip_file_exists(const char *, int, int *);
-static int _zip_headercomp(struct zip_dirent *, int,
-                           struct zip_dirent *, int);
-static unsigned char *_zip_memmem(const unsigned char *, int,
-                                  const unsigned char *, int);
-static struct zip_cdir *_zip_readcdir(FILE *, unsigned char *, unsigned char *,
-                                 int, int, struct zip_error *);
-
-
-
-ZIP_EXTERN struct zip *
-zip_open(const char *fn, int flags, int *zep)
-{
-    FILE *fp;
-    struct zip *za;
-    struct zip_cdir *cdir;
-    int i;
-    myoff_t len;
-    
-    switch (_zip_file_exists(fn, flags, zep)) {
-    case -1:
-        return NULL;
-    case 0:
-        return _zip_allocate_new(fn, zep);
-    default:
-        break;
-    }
-
-    if ((fp=fopen(fn, "rb")) == NULL) {
-        set_error(zep, NULL, ZIP_ER_OPEN);
-        return NULL;
-    }
-
-    fseeko(fp, 0, SEEK_END);
-    len = ftello(fp);
-
-    /* treat empty files as empty archives */
-    if (len == 0) {
-        if ((za=_zip_allocate_new(fn, zep)) == NULL)
-            fclose(fp);
-        else
-            za->zp = fp;
-        return za;
-    }
-
-    cdir = _zip_find_central_dir(fp, flags, zep, len);
-    if (cdir == NULL) {
-        fclose(fp);
-        return NULL;
-    }
-
-    if ((za=_zip_allocate_new(fn, zep)) == NULL) {
-        _zip_cdir_free(cdir);
-        fclose(fp);
-        return NULL;
-    }
-
-    za->cdir = cdir;
-    za->zp = fp;
-
-    if ((za->entry=(struct zip_entry *)malloc(sizeof(*(za->entry))
-                                              * cdir->nentry)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        _zip_free(za);
-        return NULL;
-    }
-    for (i=0; i<cdir->nentry; i++)
-        _zip_entry_new(za);
-
-    _zip_check_torrentzip(za);
-    za->ch_flags = za->flags;
-
-    return za;
-}
-
-
-
-static void
-set_error(int *zep, struct zip_error *err, int ze)
-{
-    int se;
-
-    if (err) {
-        _zip_error_get(err, &ze, &se);
-        if (zip_error_get_sys_type(ze) == ZIP_ET_SYS)
-            errno = se;
-    }
-
-    if (zep)
-        *zep = ze;
-}
-
-
-
-/* _zip_readcdir:
-   tries to find a valid end-of-central-directory at the beginning of
-   buf, and then the corresponding central directory entries.
-   Returns a struct zip_cdir which contains the central directory 
-   entries, or NULL if unsuccessful. */
-
-static struct zip_cdir *
-_zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
-              int flags, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    unsigned char *cdp, **bufp;
-    int i, comlen, nentry;
-
-    comlen = buf + buflen - eocd - EOCDLEN;
-    if (comlen < 0) {
-        /* not enough bytes left for comment */
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    /* check for end-of-central-dir magic */
-    if (memcmp(eocd, EOCD_MAGIC, 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    if (memcmp(eocd+4, "\0\0\0\0", 4) != 0) {
-        _zip_error_set(error, ZIP_ER_MULTIDISK, 0);
-        return NULL;
-    }
-
-    cdp = eocd + 8;
-    /* number of cdir-entries on this disk */
-    i = _zip_read2(&cdp);
-    /* number of cdir-entries */
-    nentry = _zip_read2(&cdp);
-
-    if ((cd=_zip_cdir_new(nentry, error)) == NULL)
-        return NULL;
-
-    cd->size = _zip_read4(&cdp);
-    cd->offset = _zip_read4(&cdp);
-    cd->comment = NULL;
-    cd->comment_len = _zip_read2(&cdp);
-
-    if ((comlen < cd->comment_len) || (cd->nentry != i)) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        free(cd);
-        return NULL;
-    }
-    if ((flags & ZIP_CHECKCONS) && comlen != cd->comment_len) {
-        _zip_error_set(error, ZIP_ER_INCONS, 0);
-        free(cd);
-        return NULL;
-    }
-
-    if (cd->comment_len) {
-        if ((cd->comment=(char *)_zip_memdup(eocd+EOCDLEN,
-                                             cd->comment_len, error))
-            == NULL) {
-            free(cd);
-            return NULL;
-        }
-    }
-
-    cdp = eocd;
-    if (cd->size < (unsigned int)(eocd-buf)) {
-        /* if buffer already read in, use it */
-        cdp = eocd - cd->size;
-        bufp = &cdp;
-    }
-    else {
-        /* go to start of cdir and read it entry by entry */
-        bufp = NULL;
-        clearerr(fp);
-        fseeko(fp, cd->offset, SEEK_SET);
-        /* possible consistency check: cd->offset =
-           len-(cd->size+cd->comment_len+EOCDLEN) ? */
-        if (ferror(fp) || ((unsigned long)ftello(fp) != cd->offset)) {
-            /* seek error or offset of cdir wrong */
-            if (ferror(fp))
-                _zip_error_set(error, ZIP_ER_SEEK, errno);
-            else
-                _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            free(cd);
-            return NULL;
-        }
-    }
-
-    for (i=0; i<cd->nentry; i++) {
-        if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0,
-                              error)) < 0) {
-            cd->nentry = i;
-            _zip_cdir_free(cd);
-            return NULL;
-        }
-    }
-    
-    return cd;
-}
-
-
-
-/* _zip_checkcons:
-   Checks the consistency of the central directory by comparing central
-   directory entries with local headers and checking for plausible
-   file and header offsets. Returns -1 if not plausible, else the
-   difference between the lowest and the highest fileposition reached */
-
-static int
-_zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error)
-{
-    int i;
-    unsigned int min, max, j;
-    struct zip_dirent temp;
-
-    if (cd->nentry) {
-        max = cd->entry[0].offset;
-        min = cd->entry[0].offset;
-    }
-    else
-        min = max = 0;
-
-    for (i=0; i<cd->nentry; i++) {
-        if (cd->entry[i].offset < min)
-            min = cd->entry[i].offset;
-        if (min > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        j = cd->entry[i].offset + cd->entry[i].comp_size
-            + cd->entry[i].filename_len + LENTRYSIZE;
-        if (j > max)
-            max = j;
-        if (max > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        if (fseeko(fp, cd->entry[i].offset, SEEK_SET) != 0) {
-            _zip_error_set(error, ZIP_ER_SEEK, 0);
-            return -1;
-        }
-        
-        if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1)
-            return -1;
-        
-        if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) {
-            _zip_error_set(error, ZIP_ER_INCONS, 0);
-            _zip_dirent_finalize(&temp);
-            return -1;
-        }
-        _zip_dirent_finalize(&temp);
-    }
-
-    return max - min;
-}
-
-
-
-/* _zip_check_torrentzip:
-   check wether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
-
-static void
-_zip_check_torrentzip(struct zip *za)
-{
-    uLong crc_got, crc_should;
-    char buf[8+1];
-    char *end;
-
-    if (za->zp == NULL || za->cdir == NULL)
-        return;
-
-    if (za->cdir->comment_len != TORRENT_SIG_LEN+8
-        || strncmp(za->cdir->comment, TORRENT_SIG, TORRENT_SIG_LEN) != 0)
-        return;
-
-    memcpy(buf, za->cdir->comment+TORRENT_SIG_LEN, 8);
-    buf[8] = '\0';
-    errno = 0;
-    crc_should = strtoul(buf, &end, 16);
-    if ((crc_should == UINT_MAX && errno != 0) || (end && *end))
-        return;
-
-    if (_zip_filerange_crc(za->zp, za->cdir->offset, za->cdir->size,
-                           &crc_got, NULL) < 0)
-        return;
-
-    if (crc_got == crc_should)
-        za->flags |= ZIP_AFL_TORRENT;
-}
-
-
-
-
-/* _zip_headercomp:
-   compares two headers h1 and h2; if they are local headers, set
-   local1p or local2p respectively to 1, else 0. Return 0 if they
-   are identical, -1 if not. */
-
-static int
-_zip_headercomp(struct zip_dirent *h1, int local1p, struct zip_dirent *h2,
-           int local2p)
-{
-    if ((h1->version_needed != h2->version_needed)
-#if 0
-        /* some zip-files have different values in local
-           and global headers for the bitflags */
-        || (h1->bitflags != h2->bitflags)
-#endif
-        || (h1->comp_method != h2->comp_method)
-        || (h1->last_mod != h2->last_mod)
-        || (h1->filename_len != h2->filename_len)
-        || !h1->filename || !h2->filename
-        || strcmp(h1->filename, h2->filename))
-        return -1;
-
-    /* check that CRC and sizes are zero if data descriptor is used */
-    if ((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local1p
-        && (h1->crc != 0
-            || h1->comp_size != 0
-            || h1->uncomp_size != 0))
-        return -1;
-    if ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local2p
-        && (h2->crc != 0
-            || h2->comp_size != 0
-            || h2->uncomp_size != 0))
-        return -1;
-    
-    /* check that CRC and sizes are equal if no data descriptor is used */
-    if (((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local1p == 0)
-        && ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local2p == 0)) {
-        if ((h1->crc != h2->crc)
-            || (h1->comp_size != h2->comp_size)
-            || (h1->uncomp_size != h2->uncomp_size))
-            return -1;
-    }
-    
-    if ((local1p == local2p)
-        && ((h1->extrafield_len != h2->extrafield_len)
-            || (h1->extrafield_len && h2->extrafield
-                && memcmp(h1->extrafield, h2->extrafield,
-                          h1->extrafield_len))))
-        return -1;
-
-    /* if either is local, nothing more to check */
-    if (local1p || local2p)
-        return 0;
-
-    if ((h1->version_madeby != h2->version_madeby)
-        || (h1->disk_number != h2->disk_number)
-        || (h1->int_attrib != h2->int_attrib)
-        || (h1->ext_attrib != h2->ext_attrib)
-        || (h1->offset != h2->offset)
-        || (h1->comment_len != h2->comment_len)
-        || (h1->comment_len && h2->comment
-            && memcmp(h1->comment, h2->comment, h1->comment_len)))
-        return -1;
-
-    return 0;
-}
-
-
-
-static struct zip *
-_zip_allocate_new(const char *fn, int *zep)
-{
-    struct zip *za;
-    struct zip_error error;
-
-    if ((za=_zip_new(&error)) == NULL) {
-        set_error(zep, &error, 0);
-        return NULL;
-    }
-        
-    za->zn = strdup(fn);
-    if (!za->zn) {
-        _zip_free(za);
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-    return za;
-}
-
-
-
-static int
-_zip_file_exists(const char *fn, int flags, int *zep)
-{
-    struct stat st;
-
-    if (fn == NULL) {
-        set_error(zep, NULL, ZIP_ER_INVAL);
-        return -1;
-    }
-    
-    if (stat(fn, &st) != 0) {
-        if (flags & ZIP_CREATE)
-            return 0;
-        else {
-            set_error(zep, NULL, ZIP_ER_OPEN);
-            return -1;
-        }
-    }
-    else if ((flags & ZIP_EXCL)) {
-        set_error(zep, NULL, ZIP_ER_EXISTS);
-        return -1;
-    }
-    /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
-       just like open() */
-
-    return 1;
-}
-
-
-
-static struct zip_cdir *
-_zip_find_central_dir(FILE *fp, int flags, int *zep, myoff_t len)
-{
-    struct zip_cdir *cdir, *cdirnew;
-    unsigned char *buf, *match;
-    int a, best, buflen, i;
-    struct zip_error zerr;
-
-    i = fseeko(fp, -(len < CDBUFSIZE ? len : CDBUFSIZE), SEEK_END);
-    if (i == -1 && errno != EFBIG) {
-        /* seek before start of file on my machine */
-        set_error(zep, NULL, ZIP_ER_SEEK);
-        return NULL;
-    }
-
-    /* 64k is too much for stack */
-    if ((buf=(unsigned char *)malloc(CDBUFSIZE)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-
-    clearerr(fp);
-    buflen = fread(buf, 1, CDBUFSIZE, fp);
-
-    if (ferror(fp)) {
-        set_error(zep, NULL, ZIP_ER_READ);
-        free(buf);
-        return NULL;
-    }
-    
-    best = -1;
-    cdir = NULL;
-    match = buf;
-    _zip_error_set(&zerr, ZIP_ER_NOZIP, 0);
-
-    while ((match=_zip_memmem(match, buflen-(match-buf)-18,
-                              (const unsigned char *)EOCD_MAGIC, 4))!=NULL) {
-        /* found match -- check, if good */
-        /* to avoid finding the same match all over again */
-        match++;
-        if ((cdirnew=_zip_readcdir(fp, buf, match-1, buflen, flags,
-                                   &zerr)) == NULL)
-            continue;
-
-        if (cdir) {
-            if (best <= 0)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            a = _zip_checkcons(fp, cdirnew, &zerr);
-            if (best < a) {
-                _zip_cdir_free(cdir);
-                cdir = cdirnew;
-                best = a;
-            }
-            else
-                _zip_cdir_free(cdirnew);
-        }
-        else {
-            cdir = cdirnew;
-            if (flags & ZIP_CHECKCONS)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            else
-                best = 0;
-        }
-        cdirnew = NULL;
-    }
-
-    free(buf);
-    
-    if (best < 0) {
-        set_error(zep, &zerr, 0);
-        _zip_cdir_free(cdir);
-        return NULL;
-    }
-
-    return cdir;
-}
-
-
-
-static unsigned char *
-_zip_memmem(const unsigned char *big, int biglen, const unsigned char *little, 
-       int littlelen)
-{
-    const unsigned char *p;
-    
-    if ((biglen < littlelen) || (littlelen == 0))
-        return NULL;
-    p = big-1;
-    while ((p=(const unsigned char *)
-                memchr(p+1, little[0], (size_t)(big-(p+1)+biglen-littlelen+1)))
-           != NULL) {
-        if (memcmp(p+1, little+1, littlelen-1)==0)
-            return (unsigned char *)p;
-    }
-
-    return NULL;
-}
-
-
-/* _zip_new:
-   creates a new zipfile struct, and sets the contents to zero; returns
-   the new struct. */
-
-struct zip *
-_zip_new(struct zip_error *error)
-{
-    struct zip *za;
-
-    za = (struct zip *)malloc(sizeof(struct zip));
-    if (!za) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    za->zn = NULL;
-    za->zp = NULL;
-    _zip_error_init(&za->error);
-    za->cdir = NULL;
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-    za->nentry = za->nentry_alloc = 0;
-    za->entry = NULL;
-    za->nfile = za->nfile_alloc = 0;
-    za->file = NULL;
-    za->flags = za->ch_flags = 0;
-    
-    return za;
-}
-
-
-void *
-_zip_memdup(const void *mem, size_t len, struct zip_error *error)
-{
-    void *ret;
-
-    ret = malloc(len);
-    if (!ret) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    memcpy(ret, mem, len);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_get_num_files(struct zip *za)
-{
-    if (za == NULL)
-        return -1;
-
-    return za->nentry;
-}
-
-ZIP_EXTERN const char *
-zip_get_name(struct zip *za, int idx, int flags)
-{
-    return _zip_get_name(za, idx, flags, &za->error);
-}
-
-
-
-const char *
-_zip_get_name(struct zip *za, int idx, int flags, struct zip_error *error)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0) {
-        if (za->entry[idx].state == ZIP_ST_DELETED) {
-            _zip_error_set(error, ZIP_ER_DELETED, 0);
-            return NULL;
-        }
-        if (za->entry[idx].ch_filename)
-            return za->entry[idx].ch_filename;
-    }
-
-    if (za->cdir == NULL || idx >= za->cdir->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-    
-    return za->cdir->entry[idx].filename;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_file_comment(struct zip *za, int idx, int *lenp, int flags)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->entry[idx].ch_comment_len == -1)) {
-        if (lenp != NULL)
-            *lenp = za->cdir->entry[idx].comment_len;
-        return za->cdir->entry[idx].comment;
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->entry[idx].ch_comment_len;
-    return za->entry[idx].ch_comment;
-}
-
-
-ZIP_EXTERN int
-zip_get_archive_flag(struct zip *za, int flag, int flags)
-{
-    int fl;
-
-    fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags;
-
-    return (fl & flag) ? 1 : 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_archive_comment(struct zip *za, int *lenp, int flags)
-{
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->ch_comment_len == -1)) {
-        if (za->cdir) {
-            if (lenp != NULL)
-                *lenp = za->cdir->comment_len;
-            return za->cdir->comment;
-        }
-        else {
-            if (lenp != NULL)
-                *lenp = -1;
-            return NULL;
-        }
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->ch_comment_len;
-    return za->ch_comment;
-}
-
-
-/* _zip_free:
-   frees the space allocated to a zipfile struct, and closes the
-   corresponding file. */
-
-void
-_zip_free(struct zip *za)
-{
-    int i;
-
-    if (za == NULL)
-        return;
-
-    if (za->zn)
-        free(za->zn);
-
-    if (za->zp)
-        fclose(za->zp);
-
-    _zip_cdir_free(za->cdir);
-
-    if (za->entry) {
-        for (i=0; i<za->nentry; i++) {
-            _zip_entry_free(za->entry+i);
-        }
-        free(za->entry);
-    }
-
-    for (i=0; i<za->nfile; i++) {
-        if (za->file[i]->error.zip_err == ZIP_ER_OK) {
-            _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
-            za->file[i]->za = NULL;
-        }
-    }
-
-    free(za->file);
-    
-    free(za);
-
-    return;
-}
-
-
-ZIP_EXTERN ssize_t
-zip_fread(struct zip_file *zf, void *outbuf, size_t toread)
-{
-    int ret;
-    size_t out_before, len;
-    int i;
-
-    if (!zf)
-        return -1;
-
-    if (zf->error.zip_err != 0)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || (toread == 0))
-        return 0;
-
-    if (zf->bytes_left == 0) {
-        zf->flags |= ZIP_ZF_EOF;
-        if (zf->flags & ZIP_ZF_CRC) {
-            if (zf->crc != zf->crc_orig) {
-                _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
-                return -1;
-            }
-        }
-        return 0;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0) {
-        ret = _zip_file_fillbuf(outbuf, toread, zf);
-        if (ret > 0) {
-            if (zf->flags & ZIP_ZF_CRC)
-                zf->crc = crc32(zf->crc, (Bytef *)outbuf, ret);
-            zf->bytes_left -= ret;
-        }
-        return ret;
-    }
-    
-    zf->zstr->next_out = (Bytef *)outbuf;
-    zf->zstr->avail_out = toread;
-    out_before = zf->zstr->total_out;
-    
-    /* endless loop until something has been accomplished */
-    for (;;) {
-        ret = inflate(zf->zstr, Z_SYNC_FLUSH);
-
-        switch (ret) {
-        case Z_OK:
-        case Z_STREAM_END:
-            /* all ok */
-            /* Z_STREAM_END probably won't happen, since we didn't
-               have a header */
-            len = zf->zstr->total_out - out_before;
-            if (len >= zf->bytes_left || len >= toread) {
-                if (zf->flags & ZIP_ZF_CRC)
-                    zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
-                zf->bytes_left -= len;
-                return len;
-            }
-            break;
-
-        case Z_BUF_ERROR:
-            if (zf->zstr->avail_in == 0) {
-                i = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-                if (i == 0) {
-                    _zip_error_set(&zf->error, ZIP_ER_INCONS, 0);
-                    return -1;
-                }
-                else if (i < 0)
-                    return -1;
-                zf->zstr->next_in = (Bytef *)zf->buffer;
-                zf->zstr->avail_in = i;
-                continue;
-            }
-            /* fallthrough */
-        case Z_NEED_DICT:
-        case Z_DATA_ERROR:
-        case Z_STREAM_ERROR:
-        case Z_MEM_ERROR:
-            _zip_error_set(&zf->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-    }
-}
-
-
-ZIP_EXTERN const char *
-zip_strerror(struct zip *za)
-{
-    return _zip_error_strerror(&za->error);
-}
-
-
-ZIP_EXTERN void
-zip_stat_init(struct zip_stat *st)
-{
-    st->name = NULL;
-    st->index = -1;
-    st->crc = 0;
-    st->mtime = (time_t)-1;
-    st->size = -1;
-    st->comp_size = -1;
-    st->comp_method = ZIP_CM_STORE;
-    st->encryption_method = ZIP_EM_NONE;
-}
-
-
-ZIP_EXTERN int
-zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st)
-{
-    const char *name;
-    
-    if (index < 0 || index >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((name=zip_get_name(za, index, flags)) == NULL)
-        return -1;
-    
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+index)) {
-        if (za->entry[index].source->f(za->entry[index].source->ud,
-                                     st, sizeof(*st), ZIP_SOURCE_STAT) < 0) {
-            _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-            return -1;
-        }
-    }
-    else {
-        if (za->cdir == NULL || index >= za->cdir->nentry) {
-            _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-            return -1;
-        }
-        
-        st->crc = za->cdir->entry[index].crc;
-        st->size = za->cdir->entry[index].uncomp_size;
-        st->mtime = za->cdir->entry[index].last_mod;
-        st->comp_size = za->cdir->entry[index].comp_size;
-        st->comp_method = za->cdir->entry[index].comp_method;
-        if (za->cdir->entry[index].bitflags & ZIP_GPBF_ENCRYPTED) {
-            if (za->cdir->entry[index].bitflags & ZIP_GPBF_STRONG_ENCRYPTION) {
-                /* XXX */
-                st->encryption_method = ZIP_EM_UNKNOWN;
-            }
-            else
-                st->encryption_method = ZIP_EM_TRAD_PKWARE;
-        }
-        else
-            st->encryption_method = ZIP_EM_NONE;
-        /* st->bitflags = za->cdir->entry[index].bitflags; */
-    }
-
-    st->index = index;
-    st->name = name;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_stat(struct zip *za, const char *fname, int flags, struct zip_stat *st)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return -1;
-
-    return zip_stat_index(za, idx, flags, st);
-}
-
-
-struct read_zip {
-    struct zip_file *zf;
-    struct zip_stat st;
-    myoff_t off, len;
-};
-
-static ssize_t read_zip(void *st, void *data, size_t len,
-                        enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_zip(struct zip *za, struct zip *srcza, int srcidx, int flags,
-               myoff_t start, myoff_t len)
-{
-    struct zip_error error;
-    struct zip_source *zs;
-    struct read_zip *p;
-
-    /* XXX: ZIP_FL_RECOMPRESS */
-
-    if (za == NULL)
-        return NULL;
-
-    if (srcza == NULL || start < 0 || len < -1 || srcidx < 0 || srcidx >= srcza->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(srcza->entry+srcidx)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (len == 0)
-        len = -1;
-
-    if (start == 0 && len == -1 && (flags & ZIP_FL_RECOMPRESS) == 0)
-        flags |= ZIP_FL_COMPRESSED;
-    else
-        flags &= ~ZIP_FL_COMPRESSED;
-
-    if ((p=(struct read_zip *)malloc(sizeof(*p))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-        
-    _zip_error_copy(&error, &srcza->error);
-        
-    if (zip_stat_index(srcza, srcidx, flags, &p->st) < 0
-        || (p->zf=zip_fopen_index(srcza, srcidx, flags)) == NULL) {
-        free(p);
-        _zip_error_copy(&za->error, &srcza->error);
-        _zip_error_copy(&srcza->error, &error);
-        
-        return NULL;
-    }
-    p->off = start;
-    p->len = len;
-
-    if ((flags & ZIP_FL_COMPRESSED) == 0) {
-        p->st.size = p->st.comp_size = len;
-        p->st.comp_method = ZIP_CM_STORE;
-        p->st.crc = 0;
-    }
-    
-    if ((zs=zip_source_function(za, read_zip, p)) == NULL) {
-        free(p);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_zip(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_zip *z;
-    char b[8192], *buf;
-    int i, n;
-
-    z = (struct read_zip *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        for (n=0; n<z->off; n+= i) {
-            i = (z->off-n > sizeof(b) ? sizeof(b) : z->off-n);
-            if ((i=zip_fread(z->zf, b, i)) < 0) {
-                zip_fclose(z->zf);
-                z->zf = NULL;
-                return -1;
-            }
-        }
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->len != -1)
-            n = len > z->len ? z->len : len;
-        else
-            n = len;
-        
-
-        if ((i=zip_fread(z->zf, buf, n)) < 0)
-            return -1;
-
-        if (z->len != -1)
-            z->len -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        if (len < sizeof(z->st))
-            return -1;
-        len = sizeof(z->st);
-
-        memcpy(data, &z->st, len);
-        return len;
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            zip_file_error_get(z->zf, e, e+1);
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        zip_fclose(z->zf);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_function(struct zip *za, zip_source_callback zcb, void *ud)
-{
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if ((zs=(struct zip_source *)malloc(sizeof(*zs))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    zs->f = zcb;
-    zs->ud = ud;
-    
-    return zs;
-}
-
-
-ZIP_EXTERN void
-zip_source_free(struct zip_source *source)
-{
-    if (source == NULL)
-        return;
-
-    (void)source->f(source->ud, NULL, 0, ZIP_SOURCE_FREE);
-
-    free(source);
-}
-
-
-struct read_file {
-    char *fname;        /* name of file to copy from */
-    FILE *f;                /* file to copy from */
-    myoff_t off;                /* start offset of */
-    myoff_t len;                /* lengt of data to copy */
-    myoff_t remain;        /* bytes remaining to be copied */
-    int e[2];                /* error codes */
-};
-
-static ssize_t read_file(void *state, void *data, size_t len,
-                     enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_filep(struct zip *za, FILE *file, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (file == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, NULL, file, start, len);
-}
-
-
-
-struct zip_source *
-_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file,
-                      myoff_t start, myoff_t len)
-{
-    struct read_file *f;
-    struct zip_source *zs;
-
-    if (file == NULL && fname == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->fname = NULL;
-    if (fname) {
-        if ((f->fname=strdup(fname)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(f);
-            return NULL;
-        }
-    }
-    f->f = file;
-    f->off = start;
-    f->len = (len ? len : -1);
-    
-    if ((zs=zip_source_function(za, read_file, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_file(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_file *z;
-    char *buf;
-    int i, n;
-
-    z = (struct read_file *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        if (z->fname) {
-            if ((z->f=fopen(z->fname, "rb")) == NULL) {
-                z->e[0] = ZIP_ER_OPEN;
-                z->e[1] = errno;
-                return -1;
-            }
-        }
-
-        if (fseeko(z->f, z->off, SEEK_SET) < 0) {
-            z->e[0] = ZIP_ER_SEEK;
-            z->e[1] = errno;
-            return -1;
-        }
-        z->remain = z->len;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->remain != -1)
-            n = len > z->remain ? z->remain : len;
-        else
-            n = len;
-        
-        if ((i=fread(buf, 1, n, z->f)) < 0) {
-            z->e[0] = ZIP_ER_READ;
-            z->e[1] = errno;
-            return -1;
-        }
-
-        if (z->remain != -1)
-            z->remain -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        if (z->fname) {
-            fclose(z->f);
-            z->f = NULL;
-        }
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            struct stat fst;
-            int err;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            if (z->f)
-                err = fstat(fileno(z->f), &fst);
-            else
-                err = stat(z->fname, &fst);
-
-            if (err != 0) {
-                z->e[0] = ZIP_ER_READ; /* best match */
-                z->e[1] = errno;
-                return -1;
-            }
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = fst.st_mtime;
-            if (z->len != -1)
-                st->size = z->len;
-            else if ((fst.st_mode&S_IFMT) == S_IFREG)
-                st->size = fst.st_size;
-
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        if (len < sizeof(int)*2)
-            return -1;
-
-        memcpy(data, z->e, sizeof(int)*2);
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        free(z->fname);
-        if (z->f)
-            fclose(z->f);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN int
-zip_name_locate(struct zip *za, const char *fname, int flags)
-{
-    return _zip_name_locate(za, fname, flags, &za->error);
-}
-
-
-
-int
-_zip_name_locate(struct zip *za, const char *fname, int flags,
-                 struct zip_error *error)
-{
-    int (*cmp)(const char *, const char *);
-    const char *fn, *p;
-    int i, n;
-
-    if (fname == NULL) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-    
-    cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
-
-    n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
-    for (i=0; i<n; i++) {
-        if (flags & ZIP_FL_UNCHANGED)
-            fn = za->cdir->entry[i].filename;
-        else
-            fn = _zip_get_name(za, i, flags, error);
-
-        /* newly added (partially filled) entry */
-        if (fn == NULL)
-            continue;
-        
-        if (flags & ZIP_FL_NODIR) {
-            p = strrchr(fn, '/');
-            if (p)
-                fn = p+1;
-        }
-
-        if (cmp(fname, fn) == 0)
-            return i;
-    }
-
-    _zip_error_set(error, ZIP_ER_NOENT, 0);
-    return -1;
-}
-
diff --git a/lib/wrappers/zip/zlib.nim b/lib/wrappers/zip/zlib.nim
deleted file mode 100644
index 6bb582b79..000000000
--- a/lib/wrappers/zip/zlib.nim
+++ /dev/null
@@ -1,312 +0,0 @@
-# Converted from Pascal
-
-## Interface to the zlib http://www.zlib.net/ compression library.
-
-when defined(windows):
-  const libz = "zlib1.dll"
-elif defined(macosx):
-  const libz = "libz.dylib"
-else:
-  const libz = "libz.so.1"
-
-type
-  Uint* = int32
-  Ulong* = int
-  Ulongf* = int
-  Pulongf* = ptr Ulongf
-  ZOffT* = int32
-  Pbyte* = cstring
-  Pbytef* = cstring
-  Allocfunc* = proc (p: pointer, items: Uint, size: Uint): pointer{.cdecl.}
-  FreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
-  InternalState*{.final, pure.} = object 
-  PInternalState* = ptr InternalState
-  ZStream*{.final, pure.} = object 
-    nextIn*: Pbytef
-    availIn*: Uint
-    totalIn*: Ulong
-    nextOut*: Pbytef
-    availOut*: Uint
-    totalOut*: Ulong
-    msg*: Pbytef
-    state*: PInternalState
-    zalloc*: Allocfunc
-    zfree*: FreeFunc
-    opaque*: pointer
-    dataType*: int32
-    adler*: Ulong
-    reserved*: Ulong
-
-  ZStreamRec* = ZStream
-  PZstream* = ptr ZStream
-  GzFile* = pointer
-{.deprecated: [TInternalState: InternalState, TAllocfunc: Allocfunc,
-              TFreeFunc: FreeFunc, TZStream: ZStream, TZStreamRec: ZStreamRec].}
-
-const 
-  Z_NO_FLUSH* = 0
-  Z_PARTIAL_FLUSH* = 1
-  Z_SYNC_FLUSH* = 2
-  Z_FULL_FLUSH* = 3
-  Z_FINISH* = 4
-  Z_OK* = 0
-  Z_STREAM_END* = 1
-  Z_NEED_DICT* = 2
-  Z_ERRNO* = -1
-  Z_STREAM_ERROR* = -2
-  Z_DATA_ERROR* = -3
-  Z_MEM_ERROR* = -4
-  Z_BUF_ERROR* = -5
-  Z_VERSION_ERROR* = -6
-  Z_NO_COMPRESSION* = 0
-  Z_BEST_SPEED* = 1
-  Z_BEST_COMPRESSION* = 9
-  Z_DEFAULT_COMPRESSION* = -1
-  Z_FILTERED* = 1
-  Z_HUFFMAN_ONLY* = 2
-  Z_DEFAULT_STRATEGY* = 0
-  Z_BINARY* = 0
-  Z_ASCII* = 1
-  Z_UNKNOWN* = 2
-  Z_DEFLATED* = 8
-  Z_NULL* = 0
-
-proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".}
-proc deflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflate".}
-proc deflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateEnd".}
-proc inflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflate".}
-proc inflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateEnd".}
-proc deflateSetDictionary*(strm: var ZStream, dictionary: Pbytef, 
-                           dictLength: Uint): int32{.cdecl, dynlib: libz, 
-    importc: "deflateSetDictionary".}
-proc deflateCopy*(dest, source: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateCopy".}
-proc deflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateReset".}
-proc deflateParams*(strm: var ZStream, level: int32, strategy: int32): int32{.
-    cdecl, dynlib: libz, importc: "deflateParams".}
-proc inflateSetDictionary*(strm: var ZStream, dictionary: Pbytef, 
-                           dictLength: Uint): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSetDictionary".}
-proc inflateSync*(strm: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSync".}
-proc inflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateReset".}
-proc compress*(dest: Pbytef, destLen: Pulongf, source: Pbytef, sourceLen: Ulong): cint{.
-    cdecl, dynlib: libz, importc: "compress".}
-proc compress2*(dest: Pbytef, destLen: Pulongf, source: Pbytef, 
-                sourceLen: Ulong, level: cint): cint{.cdecl, dynlib: libz, 
-    importc: "compress2".}
-proc uncompress*(dest: Pbytef, destLen: Pulongf, source: Pbytef, 
-                 sourceLen: Ulong): cint{.cdecl, dynlib: libz, 
-    importc: "uncompress".}
-proc compressBound*(sourceLen: Ulong): Ulong {.cdecl, dynlib: libz, importc.}
-proc gzopen*(path: cstring, mode: cstring): GzFile{.cdecl, dynlib: libz, 
-    importc: "gzopen".}
-proc gzdopen*(fd: int32, mode: cstring): GzFile{.cdecl, dynlib: libz, 
-    importc: "gzdopen".}
-proc gzsetparams*(thefile: GzFile, level: int32, strategy: int32): int32{.cdecl, 
-    dynlib: libz, importc: "gzsetparams".}
-proc gzread*(thefile: GzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzread".}
-proc gzwrite*(thefile: GzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzwrite".}
-proc gzprintf*(thefile: GzFile, format: Pbytef): int32{.varargs, cdecl, 
-    dynlib: libz, importc: "gzprintf".}
-proc gzputs*(thefile: GzFile, s: Pbytef): int32{.cdecl, dynlib: libz, 
-    importc: "gzputs".}
-proc gzgets*(thefile: GzFile, buf: Pbytef, length: int32): Pbytef{.cdecl, 
-    dynlib: libz, importc: "gzgets".}
-proc gzputc*(thefile: GzFile, c: char): char{.cdecl, dynlib: libz, 
-    importc: "gzputc".}
-proc gzgetc*(thefile: GzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".}
-proc gzflush*(thefile: GzFile, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "gzflush".}
-proc gzseek*(thefile: GzFile, offset: ZOffT, whence: int32): ZOffT{.cdecl, 
-    dynlib: libz, importc: "gzseek".}
-proc gzrewind*(thefile: GzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
-proc gztell*(thefile: GzFile): ZOffT{.cdecl, dynlib: libz, importc: "gztell".}
-proc gzeof*(thefile: GzFile): int {.cdecl, dynlib: libz, importc: "gzeof".}
-proc gzclose*(thefile: GzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".}
-proc gzerror*(thefile: GzFile, errnum: var int32): Pbytef{.cdecl, dynlib: libz, 
-    importc: "gzerror".}
-proc adler32*(adler: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl, 
-    dynlib: libz, importc: "adler32".}
-  ## **Warning**: Adler-32 requires at least a few hundred bytes to get rolling.
-proc crc32*(crc: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl, dynlib: libz, 
-    importc: "crc32".}
-proc deflateInitu*(strm: var ZStream, level: int32, version: cstring, 
-                   streamSize: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflateInit_".}
-proc inflateInitu*(strm: var ZStream, version: cstring,
-                   streamSize: int32): int32 {.
-    cdecl, dynlib: libz, importc: "inflateInit_".}
-proc deflateInit*(strm: var ZStream, level: int32): int32
-proc inflateInit*(strm: var ZStream): int32
-proc deflateInit2u*(strm: var ZStream, level: int32, `method`: int32, 
-                    windowBits: int32, memLevel: int32, strategy: int32, 
-                    version: cstring, streamSize: int32): int32 {.cdecl, 
-                    dynlib: libz, importc: "deflateInit2_".}
-proc inflateInit2u*(strm: var ZStream, windowBits: int32, version: cstring, 
-                    streamSize: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflateInit2_".}
-proc deflateInit2*(strm: var ZStream, 
-                   level, `method`, windowBits, memLevel,
-                   strategy: int32): int32
-proc inflateInit2*(strm: var ZStream, windowBits: int32): int32
-proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
-proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSyncPoint".}
-proc getCrcTable*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
-
-proc deflateInit(strm: var ZStream, level: int32): int32 = 
-  result = deflateInitu(strm, level, zlibVersion(), sizeof(ZStream).cint)
-
-proc inflateInit(strm: var ZStream): int32 = 
-  result = inflateInitu(strm, zlibVersion(), sizeof(ZStream).cint)
-
-proc deflateInit2(strm: var ZStream, 
-                  level, `method`, windowBits, memLevel,
-                  strategy: int32): int32 = 
-  result = deflateInit2u(strm, level, `method`, windowBits, memLevel, 
-                         strategy, zlibVersion(), sizeof(ZStream).cint)
-
-proc inflateInit2(strm: var ZStream, windowBits: int32): int32 = 
-  result = inflateInit2u(strm, windowBits, zlibVersion(), 
-                         sizeof(ZStream).cint)
-
-proc zlibAllocMem*(appData: pointer, items, size: int): pointer {.cdecl.} = 
-  result = alloc(items * size)
-
-proc zlibFreeMem*(appData, `block`: pointer) {.cdecl.} = 
-  dealloc(`block`)
-
-proc uncompress*(sourceBuf: cstring, sourceLen: int): string =
-  ## Given a deflated cstring returns its inflated version.
-  ##
-  ## Passing a nil cstring will crash this proc in release mode and assert in
-  ## debug mode.
-  ##
-  ## Returns nil on problems. Failure is a very loose concept, it could be you
-  ## passing a non deflated string, or it could mean not having enough memory
-  ## for the inflated version.
-  ##
-  ## The uncompression algorithm is based on
-  ## http://stackoverflow.com/questions/17820664 but does ignore some of the
-  ## original signed/unsigned checks, so may fail with big chunks of data
-  ## exceeding the positive size of an int32. The algorithm can deal with
-  ## concatenated deflated values properly.
-  assert (not sourceBuf.isNil)
-
-  var z: ZStream
-  # Initialize input.
-  z.nextIn = sourceBuf
-
-  # Input left to decompress.
-  var left = zlib.Uint(sourceLen)
-  if left < 1:
-    # Incomplete gzip stream, or overflow?
-    return
-
-  # Create starting space for output (guess double the input size, will grow if
-  # needed -- in an extreme case, could end up needing more than 1000 times the
-  # input size)
-  var space = zlib.Uint(left shl 1)
-  if space < left:
-    space = left
-
-  var decompressed = newStringOfCap(space)
-
-  # Initialize output.
-  z.nextOut = addr(decompressed[0])
-  # Output generated so far.
-  var have = 0
-
-  # Set up for gzip decoding.
-  z.availIn = 0;
-  var status = inflateInit2(z, (15+16))
-  if status != Z_OK:
-    # Out of memory.
-    return
-
-  # Make sure memory allocated by inflateInit2() is freed eventually.
-  defer: discard inflateEnd(z)
-
-  # Decompress all of self.
-  while true:
-    # Allow for concatenated gzip streams (per RFC 1952).
-    if status == Z_STREAM_END:
-      discard inflateReset(z)
-
-    # Provide input for inflate.
-    if z.availIn == 0:
-      # This only makes sense in the C version using unsigned values.
-      z.availIn = left
-      left -= z.availIn
-
-    # Decompress the available input.
-    while true:
-      # Allocate more output space if none left.
-      if space == have:
-        # Double space, handle overflow.
-        space = space shl 1
-        if space < have:
-          # Space was likely already maxed out.
-          discard inflateEnd(z)
-          return
-
-        # Increase space.
-        decompressed.setLen(space)
-        # Update output pointer (might have moved).
-        z.nextOut = addr(decompressed[have])
-
-      # Provide output space for inflate.
-      z.availOut = zlib.Uint(space - have)
-      have += z.availOut;
-
-      # Inflate and update the decompressed size.
-      status = inflate(z, Z_SYNC_FLUSH);
-      have -= z.availOut;
-
-      # Bail out if any errors.
-      if status != Z_OK and status != Z_BUF_ERROR and status != Z_STREAM_END:
-        # Invalid gzip stream.
-        discard inflateEnd(z)
-        return
-
-      # Repeat until all output is generated from provided input (note
-      # that even if z.avail_in is zero, there may still be pending
-      # output -- we're not done until the output buffer isn't filled)
-      if z.availOut != 0:
-        break
-    # Continue until all input consumed.
-    if left == 0 and z.availIn == 0:
-      break
-
-  # Verify that the input is a valid gzip stream.
-  if status != Z_STREAM_END:
-    # Incomplete gzip stream.
-    return
-
-  decompressed.setLen(have)
-  swap(result, decompressed)
-
-
-proc inflate*(buffer: var string): bool {.discardable.} =
-  ## Convenience proc which inflates a string containing compressed data.
-  ##
-  ## Passing a nil string will crash this proc in release mode and assert in
-  ## debug mode. It is ok to pass a buffer which doesn't contain deflated data,
-  ## in this case the proc won't modify the buffer.
-  ##
-  ## Returns true if `buffer` was successfully inflated.
-  assert (not buffer.isNil)
-  if buffer.len < 1: return
-  var temp = uncompress(addr(buffer[0]), buffer.len)
-  if not temp.isNil:
-    swap(buffer, temp)
-    result = true
diff --git a/lib/wrappers/zip/zzip.nim b/lib/wrappers/zip/zzip.nim
deleted file mode 100644
index fab7d55b3..000000000
--- a/lib/wrappers/zip/zzip.nim
+++ /dev/null
@@ -1,176 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module is an interface to the zzip library. 
-
-#   Author: 
-#   Guido Draheim <guidod@gmx.de>
-#   Tomi Ollila <Tomi.Ollila@iki.fi>
-#   Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
-#          All rights reserved, 
-#             usage allowed under the restrictions of the
-#         Lesser GNU General Public License 
-#             or alternatively the restrictions 
-#             of the Mozilla Public License 1.1
-
-when defined(windows):
-  const
-    dllname = "zzip.dll"
-else:
-  const 
-    dllname = "libzzip.so"
-
-type 
-  TZZipError* = int32 # Name conflict if we drop the `T`
-
-const
-  ZZIP_ERROR* = -4096'i32
-  ZZIP_NO_ERROR* = 0'i32            # no error, may be used if user sets it.
-  ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32  # out of memory  
-  ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32  # failed to open zipfile, see errno for details 
-  ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32  # failed to fstat zipfile, see errno for details
-  ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32  # failed to lseek zipfile, see errno for details
-  ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32  # failed to read zipfile, see errno for details  
-  ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32
-  ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32
-  ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32
-  ZZIP_ENOENT* = ZZIP_ERROR - 28'i32
-  ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32
-  ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32
-  ZZIP_UNDEF* = ZZIP_ERROR - 32'i32
-  ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32
-
-  ZZIP_CASELESS* = 1'i32 shl 12'i32
-  ZZIP_NOPATHS* = 1'i32 shl 13'i32
-  ZZIP_PREFERZIP* = 1'i32 shl 14'i32
-  ZZIP_ONLYZIP* = 1'i32 shl 16'i32
-  ZZIP_FACTORY* = 1'i32 shl 17'i32
-  ZZIP_ALLOWREAL* = 1'i32 shl 18'i32
-  ZZIP_THREADED* = 1'i32 shl 19'i32
-  
-type
-  ZZipDir* {.final, pure.} = object
-  ZZipFile* {.final, pure.} = object
-  ZZipPluginIO* {.final, pure.} = object
-
-  ZZipDirent* {.final, pure.} = object  
-    d_compr*: int32  ## compression method
-    d_csize*: int32  ## compressed size  
-    st_size*: int32  ## file size / decompressed size
-    d_name*: cstring ## file name / strdupped name
-
-  ZZipStat* = ZZipDirent
-{.deprecated: [TZZipDir: ZzipDir, TZZipFile: ZzipFile,
-              TZZipPluginIO: ZzipPluginIO, TZZipDirent: ZzipDirent,
-              TZZipStat: ZZipStat].}
-
-proc zzip_strerror*(errcode: int32): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror".}
-proc zzip_strerror_of*(dir: ptr ZZipDir): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror_of".}
-proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_errno".}
-
-proc zzip_geterror*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_error".}
-proc zzip_seterror*(dir: ptr ZZipDir, errcode: int32) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seterror".}
-proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname, 
-    importc: "zzip_compr_str".}
-proc zzip_dirhandle*(fp: ptr ZZipFile): ptr ZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirhandle".}
-proc zzip_dirfd*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirfd".}
-proc zzip_dir_real*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_real".}
-proc zzip_file_real*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_real".}
-proc zzip_realdir*(dir: ptr ZZipDir): pointer {.cdecl, dynlib: dllname, 
-    importc: "zzip_realdir".}
-proc zzip_realfd*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_realfd".}
-
-proc zzip_dir_alloc*(fileext: cstringArray): ptr ZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_alloc".}
-proc zzip_dir_free*(para1: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_free".}
-
-proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr ZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_fdopen".}
-proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr ZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open".}
-proc zzip_dir_close*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_close".}
-proc zzip_dir_read*(dir: ptr ZZipDir, dirent: ptr ZZipDirent): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_read".}
-
-proc zzip_opendir*(filename: cstring): ptr ZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_opendir".}
-proc zzip_closedir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_closedir".}
-proc zzip_readdir*(dir: ptr ZZipDir): ptr ZZipDirent {.cdecl, dynlib: dllname, 
-    importc: "zzip_readdir".}
-proc zzip_rewinddir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, 
-                                      importc: "zzip_rewinddir".}
-proc zzip_telldir*(dir: ptr ZZipDir): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_telldir".}
-proc zzip_seekdir*(dir: ptr ZZipDir, offset: int) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seekdir".}
-
-proc zzip_file_open*(dir: ptr ZZipDir, name: cstring, flags: int32): ptr ZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_file_open".}
-proc zzip_file_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_close".}
-proc zzip_file_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_file_read".}
-proc zzip_open*(name: cstring, flags: int32): ptr ZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open".}
-proc zzip_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_close".}
-proc zzip_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_read".}
-
-proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr ZZipFile): ptr ZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_freopen".}
-proc zzip_fopen*(name: cstring, mode: cstring): ptr ZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_fopen".}
-proc zzip_fread*(p: pointer, size: int, nmemb: int, 
-                 file: ptr ZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_fread".}
-proc zzip_fclose*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_fclose".}
-
-proc zzip_rewind*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_rewind".}
-proc zzip_seek*(fp: ptr ZZipFile, offset: int, whence: int32): int {.
-    cdecl, dynlib: dllname, importc: "zzip_seek".}
-proc zzip_tell*(fp: ptr ZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_tell".}
-
-proc zzip_dir_stat*(dir: ptr ZZipDir, name: cstring, zs: ptr ZZipStat, 
-                    flags: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_stat".}
-proc zzip_file_stat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_file_stat".}
-proc zzip_fstat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_fstat".}
-
-proc zzip_open_shared_io*(stream: ptr ZZipFile, name: cstring, 
-                          o_flags: int32, o_modes: int32, ext: cstringArray, 
-                          io: ptr ZZipPluginIO): ptr ZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open_shared_io".}
-proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32, 
-                       ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
-proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, 
-                          ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
-proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, 
-                           ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}