diff options
Diffstat (limited to 'lib/wrappers')
63 files changed, 3256 insertions, 26663 deletions
diff --git a/lib/wrappers/claro.nim b/lib/wrappers/claro.nim deleted file mode 100644 index d36b9f178..000000000 --- a/lib/wrappers/claro.nim +++ /dev/null @@ -1,2734 +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 - TNode* {.pure.} = object - next*: ptr TNode - prev*: ptr TNode # pointer to real structure - data*: pointer - - TList* {.pure.} = object - head*: ptr TNode - tail*: ptr TNode - count*: int32 - - -proc list_init*(){.cdecl, importc: "list_init", dynlib: clarodll.} -proc list_create*(list: ptr TList){.cdecl, importc: "list_create", - dynlib: clarodll.} -proc node_create*(): ptr TNode{.cdecl, importc: "node_create", - dynlib: clarodll.} -proc node_free*(n: ptr TNode){.cdecl, importc: "node_free", dynlib: clarodll.} -proc node_add*(data: pointer, n: ptr TNode, L: ptr TList){.cdecl, - importc: "node_add", dynlib: clarodll.} -proc node_prepend*(data: pointer, n: ptr TNode, L: ptr TList){.cdecl, - importc: "node_prepend", dynlib: clarodll.} -proc node_del*(n: ptr TNode, L: ptr TList){.cdecl, importc: "node_del", - dynlib: clarodll.} -proc node_find*(data: pointer, L: ptr TList): ptr TNode{.cdecl, - importc: "node_find", dynlib: clarodll.} -proc node_move*(n: ptr TNode, oldlist: ptr TList, newlist: ptr TList){. - cdecl, importc: "node_move", dynlib: clarodll.} - -type - TClaroObj*{.pure, inheritable.} = object - typ*: array[0..64 - 1, char] - destroy_pending*: cint - event_handlers*: TList - children*: TList - parent*: ptr TClaroObj - appdata*: pointer # !! this is for APPLICATION USE ONLY !! - - TEvent*{.pure.} = object - obj*: ptr TClaroObj # 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. - - TEventFunc* = proc (obj: ptr TClaroObj, event: ptr TEvent){.cdecl.} - TEventIfaceFunc* = proc (obj: ptr TClaroObj, event: ptr TEvent, - data: pointer){.cdecl.} - TEventHandler*{.pure.} = object - typ*: array[0..32 - 1, char] - data*: pointer - fun*: TEventFunc # the function that handles this event - - -# #define event_handler(n) void n ( TClaroObj *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 TClaroObj - ## and the size that will be requested automatically. - -proc event_get_arg_ptr*(e: ptr TEvent, arg: cint): pointer{.cdecl, - importc: "event_get_arg_ptr", dynlib: clarodll.} -proc event_get_arg_double*(e: ptr TEvent, arg: cint): cdouble{.cdecl, - importc: "event_get_arg_double", dynlib: clarodll.} -proc event_get_arg_int*(e: ptr TEvent, arg: cint): cint{.cdecl, - importc: "event_get_arg_int", dynlib: clarodll.} -proc object_create*(parent: ptr TClaroObj, size: int32, - typ: cstring): ptr TClaroObj{. - cdecl, importc: "object_create", dynlib: clarodll.} -proc object_destroy*(obj: ptr TClaroObj){.cdecl, importc: "object_destroy", - dynlib: clarodll.} -proc object_set_parent*(obj: ptr TClaroObj, parent: ptr TClaroObj){.cdecl, - importc: "object_set_parent", dynlib: clarodll.} - -##define object_cmptype(o,t) (!strcmp(((TClaroObj *)o)->type,t)) - -# event functions - -proc object_addhandler*(obj: ptr TClaroObj, event: cstring, - fun: TEventFunc){.cdecl, - importc: "object_addhandler", dynlib: clarodll.} -proc object_addhandler_interface*(obj: ptr TClaroObj, event: cstring, - fun: TEventFunc, data: pointer){.cdecl, - importc: "object_addhandler_interface", dynlib: clarodll.} -proc event_send*(obj: ptr TClaroObj, event: cstring, fmt: cstring): cint{. - varargs, cdecl, importc: "event_send", dynlib: clarodll.} -proc event_get_name*(event: ptr TEvent): 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 - TBounds*{.pure.} = object - x*: cint - y*: cint - w*: cint - h*: cint - owner*: ptr TClaroObj - - -const - cSizeRequestChanged* = 1 - -type - TFont*{.pure.} = object - used*: cint - face*: cstring - size*: cint - weight*: cint - slant*: cint - decoration*: cint - native*: pointer - - TColor*{.pure.} = object - used*: cint - r*: cfloat - g*: cfloat - b*: cfloat - a*: cfloat - - TWidget* {.pure.} = object of TClaroObj - size_req*: ptr TBounds - size*: TBounds - size_ct*: TBounds - supports_alpha*: cint - size_flags*: cint - flags*: cint - visible*: cint - notify_flags*: cint - font*: TFont - 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 - -proc clipboard_set_text*(w: ptr TWidget, 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 TClaroObj, 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 TClaroObj, 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 - TImage* {.pure.} = object of TClaroObj - width*: cint - height*: cint - native*: pointer - native2*: pointer - native3*: pointer - icon*: pointer - - -proc image_load*(parent: ptr TClaroObj, file: cstring): ptr TImage{.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 TClaroObj, data: cstring, - len: cint): ptr TImage{.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 - TStatusIcon* {.pure.} = object of TClaroObj - icon*: ptr TImage - native*: pointer - native2*: pointer - - #* - # \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 TClaroObj, icon: ptr TImage, - flags: cint): ptr TStatusIcon {. - 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 TStatusIcon, icon: ptr TImage){.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 TStatusIcon, menu: ptr TClaroObj){.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 TStatusIcon, 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 TStatusIcon, 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 TWidget){.cdecl, importc: "widget_show", - dynlib: clarodll.} -#* -# \brief Makes the specified widget invisible. -# -# \param widget A widget -# - -proc widget_hide*(widget: ptr TWidget){.cdecl, importc: "widget_hide", - dynlib: clarodll.} -#* -# \brief Enables the widget, allowing focus -# -# \param widget A widget -# - -proc widget_enable*(widget: ptr TWidget){.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 TWidget){.cdecl, importc: "widget_disable", - dynlib: clarodll.} -#* -# \brief Give focus to the specified widget -# -# \param widget A widget -# - -proc widget_focus*(widget: ptr TWidget){.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 TWidget){.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 TWidget, 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 TWidget, flags: cint){.cdecl, - importc: "widget_set_notify", dynlib: clarodll.} - - -type - TCursorType* {.size: sizeof(cint).} = enum - cCursorNormal = 0, - cCursorTextEdit = 1, - cCursorWait = 2, - cCursorPoint = 3 - -#* -# \brief Sets the mouse cursor for the widget -# -# \param widget A widget -# \param cursor A valid cCursor* value -# - -proc widget_set_cursor*(widget: ptr TWidget, cursor: TCursorType){.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 TWidget, event: ptr TEvent): 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 TBounds, 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 TBounds{.cdecl, - importc: "new_bounds", dynlib: clarodll.} -proc get_req_bounds*(widget: ptr TWidget): ptr TBounds{.cdecl, - importc: "get_req_bounds", dynlib: clarodll.} - -var - noBoundsVar: TBounds # 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 TWidget){.cdecl, importc: "widget_pre_init", - dynlib: clarodll.} -#* \internal -# \brief Internal post-inititalisation hook -# -# \param widget A widget -# - -proc widget_post_init*(widget: ptr TWidget){.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 TWidget, event: ptr TEvent){.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 - TcgraphicsCreateFunction* = proc (widget: ptr TWidget) {.cdecl.} - -proc newdefault*(parent: ptr TWidget, widget_size: int, - widget_name: cstring, size_req: ptr TBounds, flags: cint, - creator: TcgraphicsCreateFunction): ptr TWidget{.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 TWidget): 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 TWidget, 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 TWidget, 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 TWidget, 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 TWidget, 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 TWidget){.cdecl, importc: "widget_destroy", - dynlib: clarodll.} - -type - TOpenglWidget* {.pure.} = object of TWidget - gldata*: pointer - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TOpenglWidget {. - 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 TOpenglWidget) {.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 TOpenglWidget) {. - cdecl, importc: "opengl_activate", dynlib: clarodll.} - -type - TButton* {.pure.} = object of TWidget - text*: array[0..256-1, char] - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TButton {. - 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 TClaroObj, - bounds: ptr TBounds, flags: cint, - label: cstring): ptr TButton{.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 TButton, 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 TButton, image: ptr TImage){.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 - TCanvas*{.pure.} = object of TWidget - 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 - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCanvas{. - 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 TCanvas){.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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, 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 TCanvas, image: ptr TImage, 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 TCanvas, - 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 TCanvas, - text: cstring, width: cint): cint{.cdecl, - importc: "canvas_cairo_buffered_text_display_count", - dynlib: clarodll.} -proc canvas_get_cairo_context*(widget: ptr TCanvas): cairo.PContext {.cdecl, - importc: "canvas_get_cairo_context", dynlib: clarodll.} - -type - TCheckBox*{.pure.} = object of TWidget - text*: array[0..256-1, char] - checked*: cint - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCheckBox{. - 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 TClaroObj, - bounds: ptr TBounds, flags: cint, - label: cstring): ptr TCheckBox {.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 TCheckBox, 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 TCheckBox): 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 TCheckBox, checked: cint){.cdecl, - importc: "checkbox_set_checked", dynlib: clarodll.} - - -#* -# List items define items in a list_widget -# - -type - TListItem*{.pure.} = object of TClaroObj - row*: cint - native*: pointer - nativeid*: int - menu*: ptr TClaroObj - enabled*: cint - data*: ptr pointer - ListItemChildren*: TList - ListItemParent*: ptr TList - parent_item*: ptr TListItem # drawing related info, not always required - text_color*: TColor - sel_text_color*: TColor - back_color*: TColor - sel_back_color*: TColor - font*: TFont - - TListWidget* {.pure.} = object of TWidget ## List widget, base for - ## widgets containing items - columns*: cint - coltypes*: ptr cint - items*: TList - - TCombo*{.pure.} = object of TListWidget - selected*: ptr TListItem - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCombo{. - 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 TCombo, text: cstring): ptr TListItem {. - 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 TCombo, pos: cint, - text: cstring): ptr TListItem {. - 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 TCombo, item: ptr TListItem, 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 TCombo, item: ptr TListItem){.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 TCombo): ptr TListItem{.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 TCombo): 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 TCombo, item: ptr TListItem){.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 TCombo){.cdecl, importc: "combo_clear", - dynlib: clarodll.} - -type - TContainerWidget* {.pure.} = object of TWidget - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TContainerWidget{. - cdecl, importc: "container_widget_create", dynlib: clarodll.} - -proc newdialog*(parent: ptr TClaroObj, bounds: ptr TBounds, format: cstring, - flags: cint): ptr TClaroObj{.cdecl, - importc: "dialog_widget_create", dynlib: clarodll.} -proc dialog_set_text*(obj: ptr TClaroObj, 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 - TFontDialog* {.pure.} = object of TWidget - selected*: TFont - -# 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 TClaroObj, flags: cint): ptr TFontDialog {. - 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 TFontDialog, 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 TFontDialog): ptr TFont{.cdecl, - importc: "font_dialog_get_font", dynlib: clarodll.} - -type - TFrame* {.pure.} = object of TWidget - text*: array[0..256-1, char] - - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TFrame{. - 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 TClaroObj, bounds: ptr TBounds, flags: cint, - label: cstring): ptr TFrame {.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 TFrame, label: cstring){.cdecl, - importc: "frame_set_label", dynlib: clarodll.} - -type - TImageWidget* {.pure.} = object of TWidget - src*: ptr TImage - - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TImageWidget{. - 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 TClaroObj, - bounds: ptr TBounds, flags: cint, - image: ptr TImage): ptr TImageWidget{.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 TImageWidget, src: ptr TImage){.cdecl, - importc: "image_set_image", dynlib: clarodll.} - -type - TLabel*{.pure.} = object of TWidget - text*: array[0..256-1, char] - - TcLabelJustify* = enum - cLabelLeft = 0x00000001, cLabelRight = 0x00000002, - cLabelCenter = 0x00000004, cLabelFill = 0x00000008 - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TLabel{. - 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 TClaroObj, - bounds: ptr TBounds, flags: cint, - text: cstring): ptr TLabel{.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 TLabel, 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 TLabel, 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 TListWidget, 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 TClaroObj, 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 TListWidget, 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 TListWidget, - parent: ptr TListItem): ptr TListItem{. - 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 TListWidget, parent: ptr TListItem, - pos: cint): ptr TListItem {.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 TListWidget, item: ptr TListItem){. - 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 TListWidget, item: ptr TListItem, - 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 TListWidget, parent: ptr TListItem, - row: cint): ptr TListItem{.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 TListWidget, item: ptr TListItem){. - 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 TListItem, 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 TListItem, 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 TListItem, 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 TListItem, 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 TListItem, weight: cint, - slant: cint, decoration: cint){.cdecl, - importc: "list_item_set_font_extra", dynlib: clarodll.} - -type - TListbox* {.pure.} = object of TListWidget - selected*: ptr TListItem - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TListbox{. - 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 TListbox, pos: cint, - text: cstring): ptr TListItem{. - 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 TListbox, text: cstring): ptr TListItem{. - 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 TListbox, item: ptr TListItem, 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 TListbox, item: ptr TListItem){.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 TListbox): ptr TListItem{.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 TListbox): 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 TListbox, item: ptr TListItem){.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 - TListview* {.pure.} = object of TListWidget - titles*: cstringArray - nativep*: pointer - selected*: ptr TListItem - - -# 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 TClaroObj, bounds: ptr TBounds, columns: cint, - flags: cint): ptr TListview {.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 TListview): ptr TListItem{.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 TListview, pos: cint): ptr TListItem{. - 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 TListview, item: ptr TListItem, - 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 TListview, item: ptr TListItem){. - 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 TListview): ptr TListItem{.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 TListview): 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 TListview, item: ptr TListItem){.cdecl, - importc: "listview_select_item", dynlib: clarodll.} - -const - cMenuPopupAtCursor* = 1 - -type - TMenu* {.pure.} = object of TListWidget - - -#* -# \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 TClaroObj, flags: cint): ptr TMenu {.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 TMenu, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. - 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 TMenu, parent: ptr TListItem, pos: cint, - image: ptr TImage, title: cstring): ptr TListItem{. - 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 TMenu, - parent: ptr TListItem): ptr TListItem{. - 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 TMenu, parent: ptr TListItem, - pos: cint): ptr TListItem{.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 TMenu, item: ptr TListItem, 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 TMenu, item: ptr TListItem){.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 TMenu, parent: ptr TListItem): 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 TMenu, item: ptr TListItem){.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 TMenu, item: ptr TListItem){.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 TMenu, x: cint, y: cint, flags: cint){.cdecl, - importc: "menu_popup", dynlib: clarodll.} -# -# Menu modifiers -# - -const - cModifierShift* = 1 shl 0 - cModifierCommand* = 1 shl 1 - -type - TMenubar* {.pure.} = object of TListWidget - -#* -# \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 TClaroObj, flags: cint): ptr TMenubar {.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 TMenubar, item: ptr TListItem, - 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 TMenubar, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. - 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 TMenubar, parent: ptr TListItem, - pos: cint, image: ptr TImage, - title: cstring): ptr TListItem{. - 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 TMenubar, - parent: ptr TListItem): ptr TListItem{. - 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 TMenubar, parent: ptr TListItem, - pos: cint): ptr TListItem{.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 TMenubar, item: ptr TListItem, - 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 TMenubar, item: ptr TListItem) {. - 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 TMenubar, parent: ptr TListItem): 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 TMenubar, item: ptr TListItem){. - 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 TMenubar, item: ptr TListItem){. - cdecl, importc: "menubar_enable_item", dynlib: clarodll.} - -type - TProgress* {.pure.} = object of TWidget - - TcProgressStyle* = enum - cProgressLeftRight = 0x00000000, cProgressRightLeft = 0x00000001, - cProgressTopBottom = 0x00000002, cProgressBottomTop = 0x00000004 - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TProgress {. - 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 TProgress, 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 TProgress, flags: cint){.cdecl, - importc: "progress_set_orientation", dynlib: clarodll.} - -type - TRadioGroup* {.pure.} = object of TClaroObj - buttons*: TList - selected*: ptr TClaroObj - ndata*: pointer - - TRadioButton* {.pure.} = object of TWidget - text*: array[0..256-1, char] - group*: ptr TRadioGroup - - -#* -# \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 TClaroObj, flags: cint): ptr TRadioGroup {. - 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 TClaroObj, group: ptr TRadioGroup, - bounds: ptr TBounds, label: cstring, - flags: cint): ptr TRadioButton{. - 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 TRadioButton, 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 TRadioButton, group: ptr TRadioGroup){. - cdecl, importc: "radiobutton_set_group", dynlib: clarodll.} - -const - CLARO_SCROLLBAR_MAXIMUM* = 256 - -type - TScrollbar* {.pure.} = object of TWidget - min*: cint - max*: cint - pagesize*: cint - - -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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TScrollbar{. - 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 TScrollbar, 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 TScrollbar, 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 TScrollbar): 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 TScrollbar, pagesize: cint){.cdecl, - importc: "scrollbar_set_pagesize", dynlib: clarodll.} - -type - TcSplitterChildren* = enum - cSplitterFirst = 0, cSplitterSecond = 1 - TSplitterChild* {.pure.} = object - flex*: cint - size*: cint - w*: ptr TWidget - - TSplitter* {.pure.} = object of TWidget - pair*: array[0..1, TSplitterChild] - - -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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TSplitter{. - 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 TSplitter, child: cint, flex: cint, - size: cint){.cdecl, importc: "splitter_set_info", - dynlib: clarodll.} - -type - TStatusbar* {.pure.} = object of TWidget - text*: array[0..256 - 1, char] - - -#* -# \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 TClaroObj, flags: cint): ptr TStatusbar {.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 TStatusbar, 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 TImage{.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 TImage){.cdecl, - importc: "stock_add_image", dynlib: clarodll.} - -const - CLARO_TEXTAREA_MAXIMUM = (1024 * 1024) - -type - TTextArea* {.pure.} = object of TWidget - text*: array[0..CLARO_TEXTAREA_MAXIMUM - 1, char] - - -#* -# \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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTextArea{. - 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 TTextArea, 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 TTextArea): cstring{.cdecl, - importc: "textarea_get_text", dynlib: clarodll.} - -const - CLARO_TEXTBOX_MAXIMUM = 8192 - -type - TTextBox* {.pure.} = object of TWidget - text*: array[0..CLARO_TEXTBOX_MAXIMUM-1, char] - - -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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTextBox{. - 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 TTextBox, 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 TTextBox): 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 TTextBox): 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 TTextBox, pos: cint){.cdecl, - importc: "textbox_set_pos", dynlib: clarodll.} - -const - cToolbarShowText* = 1 - cToolbarShowImages* = 2 - cToolbarShowBoth* = 3 - cToolbarAutoSizeButtons* = 4 - -type - TToolbar* {.pure.} = object of TListWidget - -#* -# \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 TClaroObj, flags: cint): ptr TToolbar{.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 TToolbar, image: ptr TImage, - title: cstring, tooltip: cstring): ptr TListItem{. - 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 TToolbar, pos: cint, - image: ptr TImage, title: cstring, - tooltip: cstring): ptr TListItem{. - 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 TToolbar): ptr TListItem{.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 TToolbar, - pos: cint): ptr TListItem {. - 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 TToolbar, item: ptr TListItem, - menu: ptr TMenu){.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 TToolbar, item: ptr TListItem, - 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 TToolbar, item: ptr TListItem){. - 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 TToolbar): cint{.cdecl, - importc: "toolbar_item_count", dynlib: clarodll.} -#* -# \brief TreeView widget -# - -type - TTreeview* {.pure.} = object of TListWidget - selected*: ptr TListItem - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTreeview{. - 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 TTreeview, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. - 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 TTreeview, parent: ptr TListItem, - pos: cint, image: ptr TImage, - title: cstring): ptr TListItem{. - 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 TTreeview, item: ptr TListItem, - 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 TTreeview, item: ptr TListItem){. - 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 TTreeview, item: ptr TListItem){.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 TTreeview, item: ptr TListItem){.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 TTreeview): ptr TListItem{.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 TTreeview, parent: ptr TListItem): 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 TTreeview, item: ptr TListItem){.cdecl, - importc: "treeview_select_item", dynlib: clarodll.} - -const - cWindowModalDialog* = 1 - cWindowCenterParent* = 2 - cWindowNoResizing* = 4 - -type - TWindow* {.pure.} = object of TWidget - title*: array[0..512 - 1, char] - icon*: ptr TImage - menubar*: ptr TWidget - workspace*: ptr TWidget - exsp_tools*: cint - exsp_status*: cint - exsp_init*: cint - - -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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TWindow {. - 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 TWindow, 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 TWindow){.cdecl, importc: "window_show", - dynlib: clarodll.} -#* -# \brief Makes a window invisible -# -# \param w A valid Window widget object -# - -proc window_hide*(w: ptr TWindow){.cdecl, importc: "window_hide", - dynlib: clarodll.} -#* -# \brief Gives focus to a window -# -# \param w A valid Window widget object -# - -proc window_focus*(w: ptr TWindow){.cdecl, importc: "window_focus", - dynlib: clarodll.} -#* -# \brief Maximises a window -# -# \param w A valid Window widget object -# - -proc window_maximize*(w: ptr TWindow){.cdecl, importc: "window_maximise", - dynlib: clarodll.} -#* -# \brief Minimises a window -# -# \param w A valid Window widget object -# - -proc window_minimize*(w: ptr TWindow){.cdecl, importc: "window_minimise", - dynlib: clarodll.} -#* -# \brief Restores a window -# -# \param w A valid Window widget object -# - -proc window_restore*(w: ptr TWindow){.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 TWindow, icon: ptr TImage){.cdecl, - importc: "window_set_icon", dynlib: clarodll.} - -const - cWorkspaceTileHorizontally* = 0 - cWorkspaceTileVertically* = 1 - -type - TWorkspace*{.pure.} = object of TWidget - - TWorkspaceWindow*{.pure.} = object of TWidget - icon*: ptr TImage - title*: array[0..512 - 1, char] - workspace*: ptr TWorkspace - - -# 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 TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TWorkspace{. - 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 TWorkspace, child: ptr TClaroObj){. - 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 TWorkspace): ptr TWorkspace{.cdecl, - importc: "workspace_get_active", dynlib: clarodll.} -#* -# \brief Cascades all workspace windows -# -# \param workspace A valid workspace widget -# - -proc workspace_cascade*(workspace: ptr TWorkspace){.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 TWorkspace, 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 TClaroObj, - bounds: ptr TBounds, - flags: cint): ptr TWorkspaceWindow{. - 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 TWorkspaceWindow, - 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 TWorkspaceWindow){.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 TWorkspaceWindow){.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 TWorkspaceWindow){.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 TWorkspaceWindow){.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 TWorkspaceWindow){.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 TWorkspaceWindow, icon: ptr TImage){. - cdecl, importc: "workspace_window_set_icon", dynlib: clarodll.} - -claro_base_init() -claro_graphics_init() - -when 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 TClaroObj, event: ptr TEvent) {.cdecl.} = - textbox_set_text(t, "You pushed my button!") - var button = cast[ptr TButton](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 a3d888201..000000000 --- a/lib/wrappers/expat.nim +++ /dev/null @@ -1,877 +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 - TParserStruct{.pure, final.} = object - - PParser* = ptr TParserStruct - -# 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. -# - -type - TStatus*{.size: sizeof(cint).} = enum - STATUS_ERROR = 0, STATUS_OK = 1, STATUS_SUSPENDED = 2 - TError*{.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 - TContent_Type*{.size: sizeof(cint).} = enum - CTYPE_EMPTY = 1, CTYPE_ANY, CTYPE_MIXED, CTYPE_NAME, CTYPE_CHOICE, CTYPE_SEQ - TContent_Quant*{.size: sizeof(cint).} = enum - CQUANT_NONE, CQUANT_OPT, CQUANT_REP, CQUANT_PLUS - -# 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 - TContent*{.pure, final.} = object - typ*: TContentType - quant*: TContentQuant - name*: cstring - numchildren*: cint - children*: ptr TContent - - -# 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 - TElementDeclHandler* = proc (userData: pointer, name: cstring, - model: ptr TContent){.cdecl.} - -proc setElementDeclHandler*(parser: PParser, eldecl: TElementDeclHandler){. - 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 - TAttlistDeclHandler* = proc (userData: pointer, elname: cstring, - attname: cstring, attType: cstring, - dflt: cstring, isrequired: cint){.cdecl.} - -proc setAttlistDeclHandler*(parser: PParser, attdecl: TAttlistDeclHandler){. - 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 - TXmlDeclHandler* = proc (userData: pointer, version: cstring, - encoding: cstring, standalone: cint){.cdecl.} - -proc setXmlDeclHandler*(parser: PParser, xmldecl: TXmlDeclHandler){.cdecl, - importc: "XML_SetXmlDeclHandler", dynlib: expatDll.} -type - TMemory_Handling_Suite*{.pure, final.} = object - mallocFcn*: proc (size: int): pointer{.cdecl.} - reallocFcn*: proc (p: pointer, size: int): pointer{.cdecl.} - freeFcn*: proc (p: pointer){.cdecl.} - - -# 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 - TStartElementHandler* = proc (userData: pointer, name: cstring, - atts: cstringArray){.cdecl.} - TEndElementHandler* = proc (userData: pointer, name: cstring){.cdecl.} - -# s is not 0 terminated. - -type - TCharacterDataHandler* = proc (userData: pointer, s: cstring, len: cint){. - cdecl.} - -# target and data are 0 terminated - -type - TProcessingInstructionHandler* = proc (userData: pointer, target: cstring, - data: cstring){.cdecl.} - -# data is 0 terminated - -type - TCommentHandler* = proc (userData: pointer, data: cstring){.cdecl.} - TStartCdataSectionHandler* = proc (userData: pointer){.cdecl.} - TEndCdataSectionHandler* = proc (userData: pointer){.cdecl.} - -# 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 - TDefaultHandler* = proc (userData: pointer, s: cstring, len: cint){.cdecl.} - -# This is called for the start of the DOCTYPE declaration, before -# any DTD or internal subset is parsed. -# - -type - TStartDoctypeDeclHandler* = proc (userData: pointer, doctypeName: cstring, - sysid: cstring, pubid: cstring, - hasInternalSubset: cint){.cdecl.} - -# This is called for the start of the DOCTYPE declaration when the -# closing > is encountered, but after processing any external -# subset. -# - -type - TEndDoctypeDeclHandler* = proc (userData: pointer){.cdecl.} - -# 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 - TEntityDeclHandler* = proc (userData: pointer, entityName: cstring, - isParameterEntity: cint, value: cstring, - valueLength: cint, base: cstring, - systemId: cstring, publicId: cstring, - notationName: cstring){.cdecl.} - -proc setEntityDeclHandler*(parser: PParser, handler: TEntityDeclHandler){.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 - TUnparsedEntityDeclHandler* = proc (userData: pointer, entityName: cstring, - base: cstring, systemId: cstring, - publicId, notationName: cstring){. - cdecl.} - -# 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 - TNotationDeclHandler* = proc (userData: pointer, notationName: cstring, - base: cstring, systemId: cstring, - publicId: cstring){.cdecl.} - -# 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 - TStartNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring, - uri: cstring){.cdecl.} - TEndNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring){.cdecl.} - -# 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 - TNotStandaloneHandler* = proc (userData: pointer): cint{.cdecl.} - -# 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 - TExternalEntityRefHandler* = proc (parser: PParser, context: cstring, - base: cstring, systemId: cstring, - publicId: cstring): cint{.cdecl.} - -# 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 - TSkippedEntityHandler* = proc (userData: pointer, entityName: cstring, - isParameterEntity: cint){.cdecl.} - -# 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 - TEncoding*{.pure, final.} = object - map*: array[0..256 - 1, cint] - data*: pointer - convert*: proc (data: pointer, s: cstring): cint{.cdecl.} - release*: proc (data: pointer){.cdecl.} - - -# 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 - TUnknownEncodingHandler* = proc (encodingHandlerData: pointer, name: cstring, - info: ptr TEncoding): cint{.cdecl.} - -proc setElementHandler*(parser: PParser, start: TStartElementHandler, - endHandler: TEndElementHandler){.cdecl, - importc: "XML_SetElementHandler", dynlib: expatDll.} -proc setStartElementHandler*(parser: PParser, handler: TStartElementHandler){. - cdecl, importc: "XML_SetStartElementHandler", dynlib: expatDll.} -proc setEndElementHandler*(parser: PParser, handler: TEndElementHandler){.cdecl, - importc: "XML_SetEndElementHandler", dynlib: expatDll.} -proc setCharacterDataHandler*(parser: PParser, handler: TCharacterDataHandler){. - cdecl, importc: "XML_SetCharacterDataHandler", dynlib: expatDll.} -proc setProcessingInstructionHandler*(parser: PParser, - handler: TProcessingInstructionHandler){. - cdecl, importc: "XML_SetProcessingInstructionHandler", dynlib: expatDll.} -proc setCommentHandler*(parser: PParser, handler: TCommentHandler){.cdecl, - importc: "XML_SetCommentHandler", dynlib: expatDll.} -proc setCdataSectionHandler*(parser: PParser, start: TStartCdataSectionHandler, - endHandler: TEndCdataSectionHandler){.cdecl, - importc: "XML_SetCdataSectionHandler", dynlib: expatDll.} -proc setStartCdataSectionHandler*(parser: PParser, - start: TStartCdataSectionHandler){.cdecl, - importc: "XML_SetStartCdataSectionHandler", dynlib: expatDll.} -proc setEndCdataSectionHandler*(parser: PParser, - endHandler: TEndCdataSectionHandler){.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: TDefaultHandler){.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: TDefaultHandler){.cdecl, - importc: "XML_SetDefaultHandlerExpand", dynlib: expatDll.} -proc setDoctypeDeclHandler*(parser: PParser, start: TStartDoctypeDeclHandler, - endHandler: TEndDoctypeDeclHandler){.cdecl, - importc: "XML_SetDoctypeDeclHandler", dynlib: expatDll.} -proc setStartDoctypeDeclHandler*(parser: PParser, - start: TStartDoctypeDeclHandler){.cdecl, - importc: "XML_SetStartDoctypeDeclHandler", dynlib: expatDll.} -proc setEndDoctypeDeclHandler*(parser: PParser, - endHandler: TEndDoctypeDeclHandler){.cdecl, - importc: "XML_SetEndDoctypeDeclHandler", dynlib: expatDll.} -proc setUnparsedEntityDeclHandler*(parser: PParser, - handler: TUnparsedEntityDeclHandler){.cdecl, - importc: "XML_SetUnparsedEntityDeclHandler", dynlib: expatDll.} -proc setNotationDeclHandler*(parser: PParser, handler: TNotationDeclHandler){. - cdecl, importc: "XML_SetNotationDeclHandler", dynlib: expatDll.} -proc setNamespaceDeclHandler*(parser: PParser, - start: TStartNamespaceDeclHandler, - endHandler: TEndNamespaceDeclHandler){.cdecl, - importc: "XML_SetNamespaceDeclHandler", dynlib: expatDll.} -proc setStartNamespaceDeclHandler*(parser: PParser, - start: TStartNamespaceDeclHandler){.cdecl, - importc: "XML_SetStartNamespaceDeclHandler", dynlib: expatDll.} -proc setEndNamespaceDeclHandler*(parser: PParser, - endHandler: TEndNamespaceDeclHandler){.cdecl, - importc: "XML_SetEndNamespaceDeclHandler", dynlib: expatDll.} -proc setNotStandaloneHandler*(parser: PParser, handler: TNotStandaloneHandler){. - cdecl, importc: "XML_SetNotStandaloneHandler", dynlib: expatDll.} -proc setExternalEntityRefHandler*(parser: PParser, - handler: TExternalEntityRefHandler){.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: TSkippedEntityHandler){. - cdecl, importc: "XML_SetSkippedEntityHandler", dynlib: expatDll.} -proc setUnknownEncodingHandler*(parser: PParser, - handler: TUnknownEncodingHandler, - 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): TStatus{.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): TError{.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): TStatus{.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): TStatus{. - 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): TStatus{.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): TStatus{.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): TStatus{.cdecl, - importc: "XML_ResumeParser", dynlib: expatDll.} -type - TParsing* = enum - INITIALIZED, PARSING, FINISHED, SUSPENDED - TParsingStatus*{.pure, final.} = object - parsing*: TParsing - finalBuffer*: bool - - -# 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 TParsingStatus){.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 - TParamEntityParsing* = enum - PARAM_ENTITY_PARSING_NEVER, PARAM_ENTITY_PARSING_UNLESS_STANDALONE, - PARAM_ENTITY_PARSING_ALWAYS - -# 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: TParamEntityParsing): 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): TError{.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 TContent){.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: TError): 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 - TExpat_Version*{.pure, final.} = object - major*: cint - minor*: cint - micro*: cint - - -# Return an XML_Expat_Version structure containing numeric version -# number information for this version of expat. -# - -proc expatVersionInfo*(): TExpatVersion{.cdecl, - importc: "XML_ExpatVersionInfo", dynlib: expatDll.} -# Added in Expat 1.95.5. - -type - TFeatureEnum* = 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. - TFeature*{.pure, final.} = object - feature*: TFeatureEnum - name*: cstring - value*: int - - -proc getFeatureList*(): ptr TFeature{.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 a008da43e..f7412d2b8 100644 --- a/lib/wrappers/joyent_http_parser.nim +++ b/lib/wrappers/joyent_http_parser.nim @@ -1,20 +1,29 @@ +# +# +# 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 THttpParser, at: cstring, length: csize): cint {.cdecl.} - HttpProc* = proc (a2: ptr THttpParser): cint {.cdecl.} - THttpMethod* = enum + HttpDataProc* = proc (a2: ptr HttpParser, at: cstring, length: csize): cint {.cdecl.} + HttpProc* = proc (a2: ptr HttpParser): cint {.cdecl.} + + HttpMethod* = enum HTTP_DELETE = 0, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_CONNECT, HTTP_OPTIONS, HTTP_TRACE, HTTP_COPY, HTTP_LOCK, HTTP_MKCOL, HTTP_MOVE, HTTP_PROPFIND, HTTP_PROPPATCH, HTTP_UNLOCK, HTTP_REPORT, HTTP_MKACTIVITY, HTTP_CHECKOUT, HTTP_MERGE, HTTP_MSEARCH, HTTP_NOTIFY, HTTP_SUBSCRIBE, HTTP_UNSUBSCRIBE, HTTP_PATCH - THttpParserType* = enum + HttpParserType* = enum HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH - TParserFlag* = enum + ParserFlag* = enum F_CHUNKED = 1 shl 0, F_CONNECTION_KEEP_ALIVE = 1 shl 1, F_CONNECTION_CLOSE = 1 shl 2, @@ -22,7 +31,7 @@ type F_UPGRADE = 1 shl 4, F_SKIPBODY = 1 shl 5 - THttpErrNo* = enum + HttpErrNo* = enum HPE_OK, HPE_CB_message_begin, HPE_CB_path, HPE_CB_query_string, HPE_CB_url, HPE_CB_fragment, HPE_CB_header_field, HPE_CB_header_value, HPE_CB_headers_complete, HPE_CB_body, HPE_CB_message_complete, @@ -34,7 +43,7 @@ type HPE_INVALID_CHUNK_SIZE, HPE_INVALID_CONSTANT, HPE_INVALID_INTERNAL_STATE, HPE_STRICT, HPE_UNKNOWN - THttpParser*{.pure, final, importc: "http_parser", header: "http_parser.h".} = object + HttpParser*{.pure, final, importc: "http_parser", header: "http_parser.h".} = object typ {.importc: "type".}: char flags {.importc: "flags".}: char state*{.importc: "state".}: char @@ -50,7 +59,7 @@ type upgrade {.importc: "upgrade".}: bool data*{.importc: "data".}: pointer - THttpParserSettings*{.pure, final, importc: "http_parser_settings", header: "http_parser.h".} = object + HttpParserSettings*{.pure, final, importc: "http_parser_settings", header: "http_parser.h".} = object on_message_begin*{.importc: "on_message_begin".}: HttpProc on_url*{.importc: "on_url".}: HttpDataProc on_header_field*{.importc: "on_header_field".}: HttpDataProc @@ -58,24 +67,27 @@ type on_headers_complete*{.importc: "on_headers_complete".}: HttpProc on_body*{.importc: "on_body".}: HttpDataProc on_message_complete*{.importc: "on_message_complete".}: HttpProc +{.deprecated: [THttpMethod: HttpMethod, THttpParserType: HttpParserType, + TParserFlag: ParserFlag, THttpErrNo: HttpErrNo, + THttpParser: HttpParser, THttpParserSettings: HttpParserSettings].} -proc http_parser_init*(parser: var THttpParser, typ: THttpParserType){. +proc http_parser_init*(parser: var HttpParser, typ: HttpParserType){. importc: "http_parser_init", header: "http_parser.h".} -proc http_parser_execute*(parser: var THttpParser, - settings: var THttpParserSettings, data: cstring, +proc http_parser_execute*(parser: var HttpParser, + settings: var HttpParserSettings, data: cstring, len: csize): csize {. importc: "http_parser_execute", header: "http_parser.h".} -proc http_should_keep_alive*(parser: var THttpParser): cint{. +proc http_should_keep_alive*(parser: var HttpParser): cint{. importc: "http_should_keep_alive", header: "http_parser.h".} -proc http_method_str*(m: THttpMethod): cstring{. +proc http_method_str*(m: HttpMethod): cstring{. importc: "http_method_str", header: "http_parser.h".} -proc http_errno_name*(err: THttpErrNo): cstring{. +proc http_errno_name*(err: HttpErrNo): cstring{. importc: "http_errno_name", header: "http_parser.h".} -proc http_errno_description*(err: THttpErrNo): cstring{. +proc http_errno_description*(err: HttpErrNo): cstring{. importc: "http_errno_description", header: "http_parser.h".} diff --git a/lib/wrappers/libcurl.nim b/lib/wrappers/libcurl.nim deleted file mode 100644 index 8c962f6cb..000000000 --- a/lib/wrappers/libcurl.nim +++ /dev/null @@ -1,494 +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 Tcalloc_callback - Pclosepolicy* = ptr Tclosepolicy - Pforms* = ptr Tforms - Pftpauth* = ptr Tftpauth - Pftpmethod* = ptr Tftpmethod - Pftpssl* = ptr Tftpssl - PHTTP_VERSION* = ptr THTTP_VERSION - Phttppost* = ptr Thttppost - PPcurl_httppost* = ptr Phttppost - Pinfotype* = ptr Tinfotype - Plock_access* = ptr Tlock_access - Plock_data* = ptr Tlock_data - Pmalloc_callback* = ptr Tmalloc_callback - PNETRC_OPTION* = ptr TNETRC_OPTION - Pproxytype* = ptr Tproxytype - Prealloc_callback* = ptr Trealloc_callback - Pslist* = ptr Tslist - Psocket* = ptr Tsocket - PSSL_VERSION* = ptr TSSL_VERSION - Pstrdup_callback* = ptr Tstrdup_callback - PTIMECOND* = ptr TTIMECOND - Pversion_info_data* = ptr Tversion_info_data - Pcode* = ptr Tcode - PFORMcode* = ptr TFORMcode - Pformoption* = ptr Tformoption - PINFO* = ptr TINFO - Piocmd* = ptr Tiocmd - Pioerr* = ptr Tioerr - PM* = ptr TM - PMcode* = ptr TMcode - PMoption* = ptr TMoption - PMSG* = ptr TMSG - Poption* = ptr Toption - PSH* = ptr TSH - PSHcode* = ptr TSHcode - PSHoption* = ptr TSHoption - Pversion* = ptr Tversion - Pfd_set* = pointer - PCurl* = ptr TCurl - TCurl* = pointer - Thttppost*{.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 - - Tprogress_callback* = proc (clientp: pointer, dltotal: float64, - dlnow: float64, ultotal: float64, - ulnow: float64): int32 {.cdecl.} - Twrite_callback* = proc (buffer: cstring, size: int, nitems: int, - outstream: pointer): int{.cdecl.} - Tread_callback* = proc (buffer: cstring, size: int, nitems: int, - instream: pointer): int{.cdecl.} - Tpasswd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring, - buflen: int32): int32{.cdecl.} - Tioerr* = enum - IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST - Tiocmd* = enum - IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST - Tioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Tioerr{. - cdecl.} - Tmalloc_callback* = proc (size: int): pointer{.cdecl.} - Tfree_callback* = proc (p: pointer){.cdecl.} - Trealloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.} - Tstrdup_callback* = proc (str: cstring): cstring{.cdecl.} - Tcalloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.} - Tinfotype* = 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 - Tdebug_callback* = proc (handle: PCurl, theType: Tinfotype, data: cstring, - size: int, userptr: pointer): int32{.cdecl.} - Tcode* = 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 - Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.} - Tssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Tcode{.cdecl.} - Tproxytype* = enum - PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5 - Tftpssl* = enum - FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST - Tftpauth* = enum - FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST - Tftpmethod* = enum - FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD, - FTPMETHOD_LAST - Toption* = 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 - THTTP_VERSION* = enum - HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST - TNETRC_OPTION* = enum - NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST - TSSL_VERSION* = enum - SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3, - SSLVERSION_LAST - TTIMECOND* = enum - TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD, - TIMECOND_LAST - Tformoption* = 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 - Tforms*{.pure, final.} = object - option*: Tformoption - value*: cstring - - TFORMcode* = enum - FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL, - FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY, - FORMADD_DISABLED, FORMADD_LAST - Tformget_callback* = proc (arg: pointer, buf: cstring, length: int): int{. - cdecl.} - Tslist*{.pure, final.} = object - data*: cstring - next*: Pslist - - TINFO* = 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 - Tclosepolicy* = enum - CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED, - CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK, - CLOSEPOLICY_LAST - Tlock_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 - Tlock_access* = enum - LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2, - LOCK_ACCESS_LAST - Tlock_function* = proc (handle: PCurl, data: Tlock_data, - locktype: Tlock_access, - userptr: pointer){.cdecl.} - Tunlock_function* = proc (handle: PCurl, data: Tlock_data, userptr: pointer){. - cdecl.} - TSH* = pointer - TSHcode* = enum - SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST - TSHoption* = enum - SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, - SHOPT_USERDATA, SHOPT_LAST - Tversion* = enum - VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST - Tversion_info_data*{.pure, final.} = object - age*: Tversion - 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 - - TM* = pointer - Tsocket* = int32 - TMcode* = 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 - TMSGEnum* = enum - MSG_NONE, MSG_DONE, MSG_LAST - TMsg*{.pure, final.} = object - msg*: TMSGEnum - easy_handle*: PCurl - whatever*: pointer #data : record - # case longint of - # 0 : ( whatever : pointer ); - # 1 : ( result : CURLcode ); - # end; - - Tsocket_callback* = proc (easy: PCurl, s: Tsocket, what: int32, - userp, socketp: pointer): int32{.cdecl.} - TMoption* = enum - MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3, - MOPT_SOCKETFUNCTION = 20000 + 1 - -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): TFORMcode{.cdecl, varargs, - dynlib: libname, importc: "curl_formadd".} -proc formget*(form: Phttppost, arg: pointer, append: Tformget_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): Tcode{.cdecl, dynlib: libname, - importc: "curl_global_init".} -proc global_init_mem*(flags: int32, m: Tmalloc_callback, f: Tfree_callback, - r: Trealloc_callback, s: Tstrdup_callback, - c: Tcalloc_callback): Tcode{.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: TSHoption): TSHcode{.cdecl, varargs, - dynlib: libname, importc: "curl_share_setopt".} -proc share_cleanup*(para1: PSH): TSHcode{.cdecl, dynlib: libname, - importc: "curl_share_cleanup".} -proc version_info*(para1: Tversion): Pversion_info_data{.cdecl, dynlib: libname, - importc: "curl_version_info".} -proc easy_strerror*(para1: Tcode): cstring{.cdecl, dynlib: libname, - importc: "curl_easy_strerror".} -proc share_strerror*(para1: TSHcode): 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: Toption): Tcode{.cdecl, varargs, dynlib: libname, - importc: "curl_easy_setopt".} -proc easy_perform*(curl: PCurl): Tcode{.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: TINFO): Tcode{.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): TMcode{.cdecl, - dynlib: libname, importc: "curl_multi_add_handle".} -proc multi_remove_handle*(multi_handle: PM, handle: PCurl): TMcode{.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): TMcode{.cdecl, - dynlib: libname, importc: "curl_multi_fdset".} -proc multi_perform*(multi_handle: PM, running_handles: var int32): TMcode{. - cdecl, dynlib: libname, importc: "curl_multi_perform".} -proc multi_cleanup*(multi_handle: PM): TMcode{.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: TMcode): cstring{.cdecl, dynlib: libname, - importc: "curl_multi_strerror".} -proc multi_socket*(multi_handle: PM, s: Tsocket, running_handles: var int32): TMcode{. - cdecl, dynlib: libname, importc: "curl_multi_socket".} -proc multi_socket_all*(multi_handle: PM, running_handles: var int32): TMcode{. - cdecl, dynlib: libname, importc: "curl_multi_socket_all".} -proc multi_timeout*(multi_handle: PM, milliseconds: var int32): TMcode{.cdecl, - dynlib: libname, importc: "curl_multi_timeout".} -proc multi_setopt*(multi_handle: PM, option: TMoption): TMcode{.cdecl, varargs, - dynlib: libname, importc: "curl_multi_setopt".} -proc multi_assign*(multi_handle: PM, sockfd: Tsocket, sockp: pointer): TMcode{. - 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 *)®_args->gpr[gprcount] = (SINT64) *((SINT8 *) a); - break; - case FFI_TYPE_SINT16: - *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT16 *) a); - break; - case FFI_TYPE_SINT32: - *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT32 *) a); - break; - default: - reg_args->gpr[gprcount] = 0; - memcpy (®_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] = ®_args->sse[ssecount]; - ssecount += n; - } - else - { - avalue[i] = ®_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, ®_args->sse[ssecount++], 8); - else - memcpy (a, ®_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 1b6130103..000000000 --- a/lib/wrappers/libffi/libffi.nim +++ /dev/null @@ -1,171 +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 - TArg* = int - TSArg* = int - -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 - TType* = object - size*: int - alignment*: uint16 - typ*: uint16 - elements*: ptr ptr TType - -var - type_void* {.importc: "ffi_type_void", mylib.}: TType - type_uint8* {.importc: "ffi_type_uint8", mylib.}: TType - type_sint8* {.importc: "ffi_type_sint8", mylib.}: TType - type_uint16* {.importc: "ffi_type_uint16", mylib.}: TType - type_sint16* {.importc: "ffi_type_sint16", mylib.}: TType - type_uint32* {.importc: "ffi_type_uint32", mylib.}: TType - type_sint32* {.importc: "ffi_type_sint32", mylib.}: TType - type_uint64* {.importc: "ffi_type_uint64", mylib.}: TType - type_sint64* {.importc: "ffi_type_sint64", mylib.}: TType - type_float* {.importc: "ffi_type_float", mylib.}: TType - type_double* {.importc: "ffi_type_double", mylib.}: TType - type_pointer* {.importc: "ffi_type_pointer", mylib.}: TType - type_longdouble* {.importc: "ffi_type_longdouble", mylib.}: TType - -type - Tstatus* {.size: sizeof(cint).} = enum - OK, BAD_TYPEDEF, BAD_ABI - TTypeKind* = cuint - TCif* {.pure, final.} = object - abi*: TABI - nargs*: cuint - arg_types*: ptr ptr TType - rtype*: ptr TType - bytes*: cuint - flags*: cuint - -type - TRaw* = object - sint*: TSArg - -proc raw_call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer; - avalue: ptr TRaw) {.cdecl, importc: "ffi_raw_call", mylib.} -proc ptrarray_to_raw*(cif: var Tcif; args: ptr pointer; raw: ptr TRaw) {.cdecl, - importc: "ffi_ptrarray_to_raw", mylib.} -proc raw_to_ptrarray*(cif: var Tcif; raw: ptr TRaw; 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 TType; - atypes: ptr ptr TType): TStatus {.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 - TParamList* = array[0..100, ptr TType] - TArgList* = array[0..100, pointer] - -proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr TType; - atypes: TParamList): TStatus {.cdecl, importc: "ffi_prep_cif", - mylib.} -proc call*(cif: var Tcif; fn, rvalue: pointer; - avalue: TArgList) {.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/libsvm.nim b/lib/wrappers/libsvm.nim index 00d5ac73c..8cc314412 100644 --- a/lib/wrappers/libsvm.nim +++ b/lib/wrappers/libsvm.nim @@ -21,24 +21,24 @@ else: const svmdll* = "libsvm.so" type - Tnode*{.pure, final.} = object + Node*{.pure, final.} = object index*: cint value*: cdouble - Tproblem*{.pure, final.} = object + Problem*{.pure, final.} = object L*: cint y*: ptr cdouble - x*: ptr ptr Tnode + x*: ptr ptr Node - Ttype*{.size: sizeof(cint).} = enum + Type*{.size: sizeof(cint).} = enum C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR - TKernelType*{.size: sizeof(cint).} = enum + KernelType*{.size: sizeof(cint).} = enum LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED - Tparameter*{.pure, final.} = object - typ*: TType - kernelType*: TKernelType + Parameter*{.pure, final.} = object + typ*: Type + kernelType*: KernelType degree*: cint # for poly gamma*: cdouble # for poly/rbf/sigmoid coef0*: cdouble # for poly/sigmoid @@ -53,18 +53,19 @@ type p*: cdouble # for EPSILON_SVR shrinking*: cint # use the shrinking heuristics probability*: cint # do probability estimates - +{.deprecated: [Tnode: Node, Tproblem: Problem, Ttype: Type, + TKernelType: KernelType, Tparameter: Parameter].} # # svm_model # type - TModel*{.pure, final.} = object - param*: Tparameter # parameter + Model*{.pure, final.} = object + param*: Parameter # parameter nr_class*: cint # number of classes, = 2 in regression/one class svm L*: cint # total #SV - SV*: ptr ptr Tnode # SVs (SV[l]) + SV*: ptr ptr Node # SVs (SV[l]) sv_coef*: ptr ptr cdouble # coefficients for SVs in decision functions (sv_coef[k-1][l]) rho*: ptr cdouble # constants in decision functions (rho[k*(k-1)/2]) probA*: ptr cdouble # pariwise probability information @@ -74,42 +75,42 @@ type # nSV[0] + nSV[1] + ... + nSV[k-1] = l # XXX free_sv*: cint # 1 if svm_model is created by svm_load_model - # 0 if svm_model is created by svm_train - + # 0 if svm_model is created by svm_train +{.deprecated: [TModel: Model].} -proc train*(prob: ptr Tproblem, param: ptr Tparameter): ptr Tmodel{.cdecl, +proc train*(prob: ptr Problem, param: ptr Parameter): ptr Model{.cdecl, importc: "svm_train", dynlib: svmdll.} -proc cross_validation*(prob: ptr Tproblem, param: ptr Tparameter, nr_fold: cint, +proc cross_validation*(prob: ptr Problem, param: ptr Parameter, nr_fold: cint, target: ptr cdouble){.cdecl, importc: "svm_cross_validation", dynlib: svmdll.} -proc save_model*(model_file_name: cstring, model: ptr Tmodel): cint{.cdecl, +proc save_model*(model_file_name: cstring, model: ptr Model): cint{.cdecl, importc: "svm_save_model", dynlib: svmdll.} -proc load_model*(model_file_name: cstring): ptr Tmodel{.cdecl, +proc load_model*(model_file_name: cstring): ptr Model{.cdecl, importc: "svm_load_model", dynlib: svmdll.} -proc get_svm_type*(model: ptr Tmodel): cint{.cdecl, importc: "svm_get_svm_type", +proc get_svm_type*(model: ptr Model): cint{.cdecl, importc: "svm_get_svm_type", dynlib: svmdll.} -proc get_nr_class*(model: ptr Tmodel): cint{.cdecl, importc: "svm_get_nr_class", +proc get_nr_class*(model: ptr Model): cint{.cdecl, importc: "svm_get_nr_class", dynlib: svmdll.} -proc get_labels*(model: ptr Tmodel, label: ptr cint){.cdecl, +proc get_labels*(model: ptr Model, label: ptr cint){.cdecl, importc: "svm_get_labels", dynlib: svmdll.} -proc get_svr_probability*(model: ptr Tmodel): cdouble{.cdecl, +proc get_svr_probability*(model: ptr Model): cdouble{.cdecl, importc: "svm_get_svr_probability", dynlib: svmdll.} -proc predict_values*(model: ptr Tmodel, x: ptr Tnode, dec_values: ptr cdouble): cdouble{. +proc predict_values*(model: ptr Model, x: ptr Node, dec_values: ptr cdouble): cdouble{. cdecl, importc: "svm_predict_values", dynlib: svmdll.} -proc predict*(model: ptr Tmodel, x: ptr Tnode): cdouble{.cdecl, +proc predict*(model: ptr Model, x: ptr Node): cdouble{.cdecl, importc: "svm_predict", dynlib: svmdll.} -proc predict_probability*(model: ptr Tmodel, x: ptr Tnode, +proc predict_probability*(model: ptr Model, x: ptr Node, prob_estimates: ptr cdouble): cdouble{.cdecl, importc: "svm_predict_probability", dynlib: svmdll.} -proc free_model_content*(model_ptr: ptr Tmodel){.cdecl, +proc free_model_content*(model_ptr: ptr Model){.cdecl, importc: "svm_free_model_content", dynlib: svmdll.} -proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Tmodel){.cdecl, +proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Model){.cdecl, importc: "svm_free_and_destroy_model", dynlib: svmdll.} -proc destroy_param*(param: ptr Tparameter){.cdecl, importc: "svm_destroy_param", +proc destroy_param*(param: ptr Parameter){.cdecl, importc: "svm_destroy_param", dynlib: svmdll.} -proc check_parameter*(prob: ptr Tproblem, param: ptr Tparameter): cstring{. +proc check_parameter*(prob: ptr Problem, param: ptr Parameter): cstring{. cdecl, importc: "svm_check_parameter", dynlib: svmdll.} -proc check_probability_model*(model: ptr Tmodel): cint{.cdecl, +proc check_probability_model*(model: ptr Model): cint{.cdecl, importc: "svm_check_probability_model", dynlib: svmdll.} proc set_print_string_function*(print_func: proc (arg: cstring) {.cdecl.}){. diff --git a/lib/wrappers/libuv.nim b/lib/wrappers/libuv.nim index a52ae0f63..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/ @@ -10,15 +19,15 @@ else: import posix type - TPort* = distinct int16 ## port type + Port* = distinct int16 ## port type cssize = int coff = int csize = int - AllocProc* = proc (handle: PHandle, suggested_size: csize): TBuf {.cdecl.} - ReadProc* = proc (stream: PStream, nread: cssize, buf: TBuf) {.cdecl.} - ReadProc2* = proc (stream: PPipe, nread: cssize, buf: TBuf, pending: THandleType) {.cdecl.} + AllocProc* = proc (handle: PHandle, suggested_size: csize): Buf {.cdecl.} + ReadProc* = proc (stream: PStream, nread: cssize, buf: Buf) {.cdecl.} + ReadProc2* = proc (stream: PPipe, nread: cssize, buf: Buf, pending: HandleType) {.cdecl.} WriteProc* = proc (req: PWrite, status: cint) {.cdecl.} ConnectProc* = proc (req: PConnect, status: cint) {.cdecl.} ShutdownProc* = proc (req: PShutdown, status: cint) {.cdecl.} @@ -41,7 +50,7 @@ type FsEventProc* = proc (handle: PFsEvent, filename: cstring, events: cint, status: cint) - TErrorCode* {.size: sizeof(cint).} = enum + ErrorCode* {.size: sizeof(cint).} = enum UNKNOWN = - 1, OK = 0, EOF, EACCESS, EAGAIN, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, EALREADY, EBADF, EBUSY, ECONNABORTED, ECONNREFUSED, ECONNRESET, EDESTADDRREQ, EFAULT, EHOSTUNREACH, EINTR, EINVAL, EISCONN, @@ -50,11 +59,11 @@ type EPROTONOSUPPORT, EPROTOTYPE, ETIMEDOUT, ECHARSET, EAIFAMNOSUPPORT, EAINONAME, EAISERVICE, EAISOCKTYPE, ESHUTDOWN, EEXIST - THandleType* {.size: sizeof(cint).} = enum + HandleType* {.size: sizeof(cint).} = enum UNKNOWN_HANDLE = 0, TCP, UDP, NAMED_PIPE, TTY, FILE, TIMER, PREPARE, CHECK, IDLE, ASYNC, ARES_TASK, ARES_EVENT, PROCESS, FS_EVENT - TReqType* {.size: sizeof(cint).} = enum + ReqType* {.size: sizeof(cint).} = enum rUNKNOWN_REQ = 0, rCONNECT, rACCEPT, @@ -68,57 +77,57 @@ type rGETADDRINFO, rREQ_TYPE_PRIVATE - TErr* {.pure, final, importc: "uv_err_t", header: "uv.h".} = object - code* {.importc: "code".}: TErrorCode + Err* {.pure, final, importc: "uv_err_t", header: "uv.h".} = object + code* {.importc: "code".}: ErrorCode sys_errno* {.importc: "sys_errno_".}: cint - TFsEventType* = enum + FsEventType* = enum evRENAME = 1, evCHANGE = 2 TFsEvent* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer filename {.importc: "filename".}: cstring PFsEvent* = ptr TFsEvent - TFsEvents* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object + FsEvents* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer filename* {.importc: "filename".}: cstring - TBuf* {.pure, final, importc: "uv_buf_t", header: "uv.h"} = object + Buf* {.pure, final, importc: "uv_buf_t", header: "uv.h"} = object base* {.importc: "base".}: cstring len* {.importc: "len".}: csize - TAnyHandle* {.pure, final, importc: "uv_any_handle", header: "uv.h".} = object + AnyHandle* {.pure, final, importc: "uv_any_handle", header: "uv.h".} = object tcp* {.importc: "tcp".}: TTcp - pipe* {.importc: "pipe".}: TPipe + pipe* {.importc: "pipe".}: Pipe prepare* {.importc: "prepare".}: TPrepare check* {.importc: "check".}: TCheck idle* {.importc: "idle".}: TIdle async* {.importc: "async".}: TAsync timer* {.importc: "timer".}: TTimer - getaddrinfo* {.importc: "getaddrinfo".}: TGetaddrinfo - fs_event* {.importc: "fs_event".}: TFsEvents + getaddrinfo* {.importc: "getaddrinfo".}: Getaddrinfo + fs_event* {.importc: "fs_event".}: FsEvents - TAnyReq* {.pure, final, importc: "uv_any_req", header: "uv.h".} = object - req* {.importc: "req".}: TReq - write* {.importc: "write".}: TWrite - connect* {.importc: "connect".}: TConnect - shutdown* {.importc: "shutdown".}: TShutdown - fs_req* {.importc: "fs_req".}: Tfs - work_req* {.importc: "work_req".}: TWork + AnyReq* {.pure, final, importc: "uv_any_req", header: "uv.h".} = object + req* {.importc: "req".}: Req + write* {.importc: "write".}: Write + connect* {.importc: "connect".}: Connect + shutdown* {.importc: "shutdown".}: Shutdown + fs_req* {.importc: "fs_req".}: Fs + work_req* {.importc: "work_req".}: Work ## better import this uint64 = int64 - TCounters* {.pure, final, importc: "uv_counters_t", header: "uv.h".} = object + Counters* {.pure, final, importc: "uv_counters_t", header: "uv.h".} = object eio_init* {.importc: "eio_init".}: uint64 req_init* {.importc: "req_init".}: uint64 handle_init* {.importc: "handle_init".}: uint64 @@ -135,36 +144,36 @@ type process_init* {.importc: "process_init".}: uint64 fs_event_init* {.importc: "fs_event_init".}: uint64 - TLoop* {.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? + 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? 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 - counters* {.importc: "counters".}: TCounters - last_err* {.importc: "last_err".}: TErr + counters* {.importc: "counters".}: Counters + last_err* {.importc: "last_err".}: Err data* {.importc: "data".}: pointer - PLoop* = ptr TLoop + PLoop* = ptr Loop - TShutdown* {.pure, final, importc: "uv_shutdown_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Shutdown* {.pure, final, importc: "uv_shutdown_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer handle* {.importc: "handle".}: PStream cb* {.importc: "cb".}: ShutdownProc - PShutdown* = ptr TShutdown + PShutdown* = ptr Shutdown - THandle* {.pure, final, importc: "uv_handle_t", header: "uv.h".} = object + Handle* {.pure, final, importc: "uv_handle_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer - PHandle* = ptr THandle + PHandle* = ptr Handle - TStream* {.pure, final, importc: "uv_stream_t", header: "uv.h".} = object + Stream* {.pure, final, importc: "uv_stream_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -172,20 +181,20 @@ type data* {.importc: "data".}: pointer write_queue_size* {.importc: "write_queue_size".}: csize - PStream* = ptr TStream + PStream* = ptr Stream - TWrite* {.pure, final, importc: "uv_write_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Write* {.pure, final, importc: "uv_write_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer cb* {.importc: "cb".}: WriteProc send_handle* {.importc: "send_handle".}: PStream handle* {.importc: "handle".}: PStream - PWrite* = ptr TWrite + PWrite* = ptr Write TTcp* {.pure, final, importc: "uv_tcp_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -195,42 +204,42 @@ type PTcp* = ptr TTcp - TConnect* {.pure, final, importc: "uv_connect_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Connect* {.pure, final, importc: "uv_connect_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer cb* {.importc: "cb".}: ConnectProc handle* {.importc: "handle".}: PStream - PConnect* = ptr TConnect + PConnect* = ptr Connect - TUdpFlags* = enum + UdpFlags* = enum UDP_IPV6ONLY = 1, UDP_PARTIAL = 2 ## XXX: better import this cunsigned = int UdpSendProc* = proc (req: PUdpSend, status: cint) - UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: TBuf, adr: ptr SockAddr, flags: cunsigned) + UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: Buf, adr: ptr SockAddr, flags: cunsigned) TUdp* {.pure, final, importc: "uv_udp_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer PUdp* = ptr TUdp - TUdpSend* {.pure, final, importc: "uv_udp_send_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + UdpSend* {.pure, final, importc: "uv_udp_send_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer handle* {.importc: "handle".}: PUdp cb* {.importc: "cb".}: UdpSendProc - PUdpSend* = ptr TUdpSend + PUdpSend* = ptr UdpSend tTTy* {.pure, final, importc: "uv_tty_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -240,9 +249,9 @@ type pTTy* = ptr tTTy - TPipe* {.pure, final, importc: "uv_pipe_t", header: "uv.h".} = object + Pipe* {.pure, final, importc: "uv_pipe_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -251,11 +260,11 @@ type write_queue_size* {.importc: "write_queue_size".}: csize ipc {.importc: "ipc".}: int - PPipe* = ptr TPipe + PPipe* = ptr Pipe TPrepare* {.pure, final, importc: "uv_prepare_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -263,7 +272,7 @@ type TCheck* {.pure, final, importc: "uv_check_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -271,7 +280,7 @@ type TIdle* {.pure, final, importc: "uv_idle_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -279,7 +288,7 @@ type TAsync* {.pure, final, importc: "uv_async_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -287,20 +296,20 @@ type TTimer* {.pure, final, importc: "uv_timer_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer PTimer* = ptr TTimer - TGetAddrInfo* {.pure, final, importc: "uv_getaddrinfo_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + GetAddrInfo* {.pure, final, importc: "uv_getaddrinfo_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop - PGetAddrInfo* = ptr TGetAddrInfo + PGetAddrInfo* = ptr GetAddrInfo - TProcessOptions* {.pure, final, importc: "uv_process_options_t", header: "uv.h".} = object + ProcessOptions* {.pure, final, importc: "uv_process_options_t", header: "uv.h".} = object exit_cb* {.importc: "exit_cb".}: ExitProc file* {.importc: "file".}: cstring args* {.importc: "args".}: cstringArray @@ -311,11 +320,11 @@ type stdout_stream* {.importc: "stdout_stream".}: PPipe stderr_stream* {.importc: "stderr_stream".}: PPipe - PProcessOptions* = ptr TProcessOptions + PProcessOptions* = ptr ProcessOptions TProcess* {.pure, final, importc: "uv_process_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer exit_cb* {.importc: "exit_cb".}: ExitProc @@ -323,47 +332,47 @@ type PProcess* = ptr TProcess - TWork* {.pure, final, importc: "uv_work_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Work* {.pure, final, importc: "uv_work_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop work_cb* {.importc: "work_cb".}: WorkProc after_work_cb* {.importc: "after_work_cb".}: AfterWorkProc - PWork* = ptr TWork + PWork* = ptr Work - TFsType* {.size: sizeof(cint).} = enum + FsType* {.size: sizeof(cint).} = enum FS_UNKNOWN = - 1, FS_CUSTOM, FS_OPEN, FS_CLOSE, FS_READ, FS_WRITE, FS_SENDFILE, FS_STAT, FS_LSTAT, FS_FSTAT, FS_FTRUNCATE, FS_UTIME, FS_FUTIME, FS_CHMOD, FS_FCHMOD, FS_FSYNC, FS_FDATASYNC, FS_UNLINK, FS_RMDIR, FS_MKDIR, FS_RENAME, FS_READDIR, FS_LINK, FS_SYMLINK, FS_READLINK, FS_CHOWN, FS_FCHOWN - TFS* {.pure, final, importc: "uv_fs_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + FS* {.pure, final, importc: "uv_fs_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop - fs_type* {.importc: "fs_type".}: TFsType + fs_type* {.importc: "fs_type".}: FsType cb* {.importc: "cb".}: FsProc result* {.importc: "result".}: cssize fsPtr* {.importc: "ptr".}: pointer path* {.importc: "path".}: cstring errorno* {.importc: "errorno".}: cint - PFS* = ptr TFS + PFS* = ptr FS - TReq* {.pure, final, importc: "uv_req_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Req* {.pure, final, importc: "uv_req_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer - PReq* = ptr TReq + PReq* = ptr Req - TAresOptions* {.pure, final, importc: "ares_options", header: "uv.h".} = object + AresOptions* {.pure, final, importc: "ares_options", header: "uv.h".} = object flags* {.importc: "flags".}: int timeout* {.importc: "timeout".}: int tries* {.importc: "tries".}: int ndots* {.importc: "ndots".}: int - udp_port* {.importc: "udp_port".}: TPort - tcp_port* {.importc: "tcp_port".}: TPort + udp_port* {.importc: "udp_port".}: Port + tcp_port* {.importc: "tcp_port".}: Port socket_send_buffer_size* {.importc: "socket_send_buffer_size".}: int socket_recv_buffer_size* {.importc: "socket_receive_buffer_size".}: int servers* {.importc: "servers".}: ptr InAddr @@ -378,8 +387,30 @@ type #struct apattern *sortlist; #int nsort; - PAresOptions* = ptr TAresOptions + PAresOptions* = ptr AresOptions PAresChannel* = pointer +{.deprecated: [THandle: Handle, THandleType: HandleType, TAnyHandle: AnyHandle, + TAnyReq: AnyReq, TPort: Port, TErrorCode: ErrorCode, TReqType: ReqType, + TErr: Err, TFsEventType: FsEventType, + # TFsEvent: FsEvent, # Name conflict if we drop `T` + TFsEvents: FsEvents, TBuf: Buf, TCounters: Counters, TLoop: Loop, + TShutdown: Shutdown, TStream: Stream, TWrite: Write, + # TTcp: Tcp, # Name conflict if we drop `T` + TConnect: Connect, + TUdpFlags: UdpFlags, + # TUdp: Udp, # Name conflict if we drop `T` + TUdpSend: UdpSend, + # tTTy: TTy, # Name conflict if we drop `T` + TPipe: Pipe, + # TPrepare: Prepare, # Name conflict if we drop `T` + # TCheck: Check, # Name conflict if we drop `T` + # TIdle: Idle, # Name conflict if we drop `T` + # TAsync: Async, # Name conflict if we drop `T` + # TTimer: Timer, # Name conflict if we drop `T` + TGetAddrInfo: GetAddrInfo, TProcessOptions: ProcessOptions, + # TProcess: Process, # Name conflict if we drop `T` + TWork: Work, + TFsType: FsType, TFS: FS, TReq: Req, TAresOptions: AresOptions].} proc loop_new*(): PLoop{. importc: "uv_loop_new", header: "uv.h".} @@ -405,13 +436,13 @@ proc update_time*(a2: PLoop){. proc now*(a2: PLoop): int64{. importc: "uv_now", header: "uv.h".} -proc last_error*(a2: PLoop): TErr{. +proc last_error*(a2: PLoop): Err{. importc: "uv_last_error", header: "uv.h".} -proc strerror*(err: TErr): cstring{. +proc strerror*(err: Err): cstring{. importc: "uv_strerror", header: "uv.h".} -proc err_name*(err: TErr): cstring{. +proc err_name*(err: Err): cstring{. importc: "uv_err_name", header: "uv.h".} proc shutdown*(req: PShutdown, handle: PStream, cb: ShutdownProc): cint{. @@ -423,7 +454,7 @@ proc is_active*(handle: PHandle): cint{. proc close*(handle: PHandle, close_cb: CloseProc){. importc: "uv_close", header: "uv.h".} -proc buf_init*(base: cstring, len: csize): TBuf{. +proc buf_init*(base: cstring, len: csize): Buf{. importc: "uv_buf_init", header: "uv.h".} proc listen*(stream: PStream, backlog: cint, cb: ConnectionProc): cint{. @@ -441,10 +472,10 @@ proc read_start*(a2: PStream, alloc_cb: AllocProc, read_cb: ReadProc2): cint{. proc read_stop*(a2: PStream): cint{. importc: "uv_read_stop", header: "uv.h".} -proc write*(req: PWrite, handle: PStream, bufs: ptr TBuf, bufcnt: cint, cb: WriteProc): cint{. +proc write*(req: PWrite, handle: PStream, bufs: ptr Buf, bufcnt: cint, cb: WriteProc): cint{. importc: "uv_write", header: "uv.h".} -proc write*(req: PWrite, handle: PStream, bufs: ptr TBuf, bufcnt: cint, send_handle: PStream, cb: WriteProc): cint{. +proc write*(req: PWrite, handle: PStream, bufs: ptr Buf, bufcnt: cint, send_handle: PStream, cb: WriteProc): cint{. importc: "uv_write2", header: "uv.h".} proc tcp_init*(a2: PLoop, handle: PTcp): cint{. @@ -480,10 +511,10 @@ proc udp_bind6*(handle: PUdp, adr: TSockAddrIn6, flags: cunsigned): cint{. proc udp_getsockname*(handle: PUdp, name: ptr SockAddr, namelen: var cint): cint{. importc: "uv_udp_getsockname", header: "uv.h".} -proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: SockAddrIn, send_cb: UdpSendProc): cint{. +proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr Buf, bufcnt: cint, adr: SockAddrIn, send_cb: UdpSendProc): cint{. importc: "uv_udp_send", header: "uv.h".} -proc udp_send6*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: TSockAddrIn6, send_cb: UdpSendProc): cint{. +proc udp_send6*(req: PUdpSend, handle: PUdp, bufs: ptr Buf, bufcnt: cint, adr: TSockAddrIn6, send_cb: UdpSendProc): cint{. importc: "uv_udp_send6", header: "uv.h".} proc udp_recv_start*(handle: PUdp, alloc_cb: AllocProc, recv_cb: UdpRecvProc): cint{. @@ -504,7 +535,7 @@ proc tty_get_winsize*(a2: pTTy, width: var cint, height: var cint): cint{. proc tty_reset_mode*() {. importc: "uv_tty_reset_mode", header: "uv.h".} -proc guess_handle*(file: File): THandleType{. +proc guess_handle*(file: File): HandleType{. importc: "uv_guess_handle", header: "uv.h".} proc pipe_init*(a2: PLoop, handle: PPipe, ipc: int): cint{. @@ -582,7 +613,7 @@ proc getaddrinfo*(a2: PLoop, handle: PGetAddrInfo,getaddrinfo_cb: GetAddrInfoPro proc freeaddrinfo*(ai: ptr AddrInfo){. importc: "uv_freeaddrinfo", header: "uv.h".} -proc spawn*(a2: PLoop, a3: PProcess, options: TProcessOptions): cint{. +proc spawn*(a2: PLoop, a3: PProcess, options: ProcessOptions): cint{. importc: "uv_spawn", header: "uv.h".} proc process_kill*(a2: PProcess, signum: cint): cint{. diff --git a/lib/wrappers/linenoise/LICENSE.txt b/lib/wrappers/linenoise/LICENSE.txt new file mode 100644 index 000000000..18e814865 --- /dev/null +++ b/lib/wrappers/linenoise/LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com> +Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com> + +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. + +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. diff --git a/lib/wrappers/linenoise/README.markdown b/lib/wrappers/linenoise/README.markdown new file mode 100644 index 000000000..c845673cd --- /dev/null +++ b/lib/wrappers/linenoise/README.markdown @@ -0,0 +1,52 @@ +# Linenoise + +A minimal, zero-config, BSD licensed, readline replacement used in Redis, +MongoDB, and Android. + +* Single and multi line editing mode with the usual key bindings implemented. +* History handling. +* Completion. +* About 1,100 lines of BSD license source code. +* Only uses a subset of VT100 escapes (ANSI.SYS compatible). + +## Can a line editing library be 20k lines of code? + +Line editing with some support for history is a really important feature for command line utilities. Instead of retyping almost the same stuff again and again it's just much better to hit the up arrow and edit on syntax errors, or in order to try a slightly different command. But apparently code dealing with terminals is some sort of Black Magic: readline is 30k lines of code, libedit 20k. Is it reasonable to link small utilities to huge libraries just to get a minimal support for line editing? + +So what usually happens is either: + + * Large programs with configure scripts disabling line editing if readline is not present in the system, or not supporting it at all since readline is GPL licensed and libedit (the BSD clone) is not as known and available as readline is (Real world example of this problem: Tclsh). + * Smaller programs not using a configure script not supporting line editing at all (A problem we had with Redis-cli for instance). + +The result is a pollution of binaries without line editing support. + +So I spent more or less two hours doing a reality check resulting in this little library: is it *really* needed for a line editing library to be 20k lines of code? Apparently not, it is possibe to get a very small, zero configuration, trivial to embed library, that solves the problem. Smaller programs will just include this, supporing line editing out of the box. Larger programs may use this little library or just checking with configure if readline/libedit is available and resorting to linenoise if not. + +## Terminals, in 2010. + +Apparently almost every terminal you can happen to use today has some kind of support for basic VT100 escape sequences. So I tried to write a lib using just very basic VT100 features. The resulting library appears to work everywhere I tried to use it, and now can work even on ANSI.SYS compatible terminals, since no +VT220 specific sequences are used anymore. + +The library is currently about 1100 lines of code. In order to use it in your project just look at the *example.c* file in the source distribution, it is trivial. Linenoise is BSD code, so you can use both in free software and commercial software. + +## Tested with... + + * Linux text only console ($TERM = linux) + * Linux KDE terminal application ($TERM = xterm) + * Linux xterm ($TERM = xterm) + * Linux Buildroot ($TERM = vt100) + * Mac OS X iTerm ($TERM = xterm) + * Mac OS X default Terminal.app ($TERM = xterm) + * OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen) + * IBM AIX 6.1 + * FreeBSD xterm ($TERM = xterm) + * ANSI.SYS + +Please test it everywhere you can and report back! + +## Let's push this forward! + +Patches should be provided in the respect of linenoise sensibility for small +easy to understand code. + +Send feedbacks to antirez at gmail diff --git a/lib/wrappers/linenoise/clinenoise.c b/lib/wrappers/linenoise/clinenoise.c new file mode 100644 index 000000000..b4ae32472 --- /dev/null +++ b/lib/wrappers/linenoise/clinenoise.c @@ -0,0 +1,1107 @@ +/* linenoise.c -- VERSION 1.0 + * + * Guerrilla line editing library against the idea that a line editing lib + * needs to be 20,000 lines of C code. + * + * You can find the latest source code at: + * + * http://github.com/antirez/linenoise + * + * Does a number of crazy assumptions that happen to be true in 99.9999% of + * the 2010 UNIX computers around. + * + * ------------------------------------------------------------------------ + * + * Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com> + * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com> + * + * 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. + * + * 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 + * HOLDER 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. + * + * ------------------------------------------------------------------------ + * + * References: + * - http://invisible-island.net/xterm/ctlseqs/ctlseqs.html + * - http://www.3waylabs.com/nw/WWW/products/wizcon/vt220.html + * + * Todo list: + * - Filter bogus Ctrl+<char> combinations. + * - Win32 support + * + * Bloat: + * - History search like Ctrl+r in readline? + * + * List of escape sequences used by this program, we do everything just + * with three sequences. In order to be so cheap we may have some + * flickering effect with some slow terminal, but the lesser sequences + * the more compatible. + * + * EL (Erase Line) + * Sequence: ESC [ n K + * Effect: if n is 0 or missing, clear from cursor to end of line + * Effect: if n is 1, clear from beginning of line to cursor + * Effect: if n is 2, clear entire line + * + * CUF (CUrsor Forward) + * Sequence: ESC [ n C + * Effect: moves cursor forward n chars + * + * CUB (CUrsor Backward) + * Sequence: ESC [ n D + * Effect: moves cursor backward n chars + * + * The following is used to get the terminal width if getting + * the width with the TIOCGWINSZ ioctl fails + * + * DSR (Device Status Report) + * Sequence: ESC [ 6 n + * Effect: reports the current cusor position as ESC [ n ; m R + * where n is the row and m is the column + * + * When multi line mode is enabled, we also use an additional escape + * sequence. However multi line editing is disabled by default. + * + * CUU (Cursor Up) + * Sequence: ESC [ n A + * Effect: moves cursor up of n chars. + * + * CUD (Cursor Down) + * Sequence: ESC [ n B + * Effect: moves cursor down of n chars. + * + * When linenoiseClearScreen() is called, two additional escape sequences + * are used in order to clear the screen and position the cursor at home + * position. + * + * CUP (Cursor position) + * Sequence: ESC [ H + * Effect: moves the cursor to upper left corner + * + * ED (Erase display) + * Sequence: ESC [ 2 J + * Effect: clear the whole screen + * + */ + +#include <termios.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <unistd.h> +#include "clinenoise.h" + +#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 +#define LINENOISE_MAX_LINE 4096 +static char *unsupported_term[] = {"dumb","cons25","emacs",NULL}; +static linenoiseCompletionCallback *completionCallback = NULL; + +static struct termios orig_termios; /* In order to restore at exit.*/ +static int rawmode = 0; /* For atexit() function to check if restore is needed*/ +static int mlmode = 0; /* Multi line mode. Default is single line. */ +static int atexit_registered = 0; /* Register atexit just 1 time. */ +static int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN; +static int history_len = 0; +static char **history = NULL; + +/* The linenoiseState structure represents the state during line editing. + * We pass this state to functions implementing specific editing + * functionalities. */ +struct linenoiseState { + int ifd; /* Terminal stdin file descriptor. */ + int ofd; /* Terminal stdout file descriptor. */ + char *buf; /* Edited line buffer. */ + size_t buflen; /* Edited line buffer size. */ + const char *prompt; /* Prompt to display. */ + size_t plen; /* Prompt length. */ + size_t pos; /* Current cursor position. */ + size_t oldpos; /* Previous refresh cursor position. */ + size_t len; /* Current edited line length. */ + size_t cols; /* Number of columns in terminal. */ + size_t maxrows; /* Maximum num of rows used so far (multiline mode) */ + int history_index; /* The history index we are currently editing. */ +}; + +enum KEY_ACTION{ + KEY_NULL = 0, /* NULL */ + CTRL_A = 1, /* Ctrl+a */ + CTRL_B = 2, /* Ctrl-b */ + CTRL_C = 3, /* Ctrl-c */ + CTRL_D = 4, /* Ctrl-d */ + CTRL_E = 5, /* Ctrl-e */ + CTRL_F = 6, /* Ctrl-f */ + CTRL_H = 8, /* Ctrl-h */ + TAB = 9, /* Tab */ + CTRL_K = 11, /* Ctrl+k */ + CTRL_L = 12, /* Ctrl+l */ + ENTER = 13, /* Enter */ + CTRL_N = 14, /* Ctrl-n */ + CTRL_P = 16, /* Ctrl-p */ + CTRL_T = 20, /* Ctrl-t */ + CTRL_U = 21, /* Ctrl+u */ + CTRL_W = 23, /* Ctrl+w */ + ESC = 27, /* Escape */ + BACKSPACE = 127 /* Backspace */ +}; + +static void linenoiseAtExit(void); +int linenoiseHistoryAdd(const char *line); +static void refreshLine(struct linenoiseState *l); + +/* Debugging macro. */ +#if 0 +FILE *lndebug_fp = NULL; +#define lndebug(...) \ + do { \ + if (lndebug_fp == NULL) { \ + lndebug_fp = fopen("/tmp/lndebug.txt","a"); \ + fprintf(lndebug_fp, \ + "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \ + (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \ + (int)l->maxrows,old_rows); \ + } \ + fprintf(lndebug_fp, ", " __VA_ARGS__); \ + fflush(lndebug_fp); \ + } while (0) +#else +#define lndebug(fmt, ...) +#endif + +/* ======================= Low level terminal handling ====================== */ + +/* Set if to use or not the multi line mode. */ +void linenoiseSetMultiLine(int ml) { + mlmode = ml; +} + +/* Return true if the terminal name is in the list of terminals we know are + * not able to understand basic escape sequences. */ +static int isUnsupportedTerm(void) { + char *term = getenv("TERM"); + int j; + + if (term == NULL) return 0; + for (j = 0; unsupported_term[j]; j++) + if (!strcasecmp(term,unsupported_term[j])) return 1; + return 0; +} + +/* Raw mode: 1960 magic shit. */ +static int enableRawMode(int fd) { + struct termios raw; + + if (!isatty(STDIN_FILENO)) goto fatal; + if (!atexit_registered) { + atexit(linenoiseAtExit); + atexit_registered = 1; + } + if (tcgetattr(fd,&orig_termios) == -1) goto fatal; + + raw = orig_termios; /* modify the original mode */ + /* input modes: no break, no CR to NL, no parity check, no strip char, + * no start/stop output control. */ + raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + /* output modes - disable post processing */ + raw.c_oflag &= ~(OPOST); + /* control modes - set 8 bit chars */ + raw.c_cflag |= (CS8); + /* local modes - choing off, canonical off, no extended functions, + * no signal chars (^Z,^C) */ + raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + /* control chars - set return condition: min number of bytes and timer. + * We want read to return every single byte, without timeout. */ + raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */ + + /* put terminal in raw mode after flushing */ + if (tcsetattr(fd,TCSAFLUSH,&raw) < 0) goto fatal; + rawmode = 1; + return 0; + +fatal: + errno = ENOTTY; + return -1; +} + +static void disableRawMode(int fd) { + /* Don't even check the return value as it's too late. */ + if (rawmode && tcsetattr(fd,TCSAFLUSH,&orig_termios) != -1) + rawmode = 0; +} + +/* Use the ESC [6n escape sequence to query the horizontal cursor position + * and return it. On error -1 is returned, on success the position of the + * cursor. */ +static int getCursorPosition(int ifd, int ofd) { + char buf[32]; + int cols, rows; + unsigned int i = 0; + + /* Report cursor location */ + if (write(ofd, "\x1b[6n", 4) != 4) return -1; + + /* Read the response: ESC [ rows ; cols R */ + while (i < sizeof(buf)-1) { + if (read(ifd,buf+i,1) != 1) break; + if (buf[i] == 'R') break; + i++; + } + buf[i] = '\0'; + + /* Parse it. */ + if (buf[0] != ESC || buf[1] != '[') return -1; + if (sscanf(buf+2,"%d;%d",&rows,&cols) != 2) return -1; + return cols; +} + +/* Try to get the number of columns in the current terminal, or assume 80 + * if it fails. */ +static int getColumns(int ifd, int ofd) { + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) { + /* ioctl() failed. Try to query the terminal itself. */ + int start, cols; + + /* Get the initial position so we can restore it later. */ + start = getCursorPosition(ifd,ofd); + if (start == -1) goto failed; + + /* Go to right margin and get position. */ + if (write(ofd,"\x1b[999C",6) != 6) goto failed; + cols = getCursorPosition(ifd,ofd); + if (cols == -1) goto failed; + + /* Restore position. */ + if (cols > start) { + char seq[32]; + snprintf(seq,32,"\x1b[%dD",cols-start); + if (write(ofd,seq,strlen(seq)) == -1) { + /* Can't recover... */ + } + } + return cols; + } else { + return ws.ws_col; + } + +failed: + return 80; +} + +/* Clear the screen. Used to handle ctrl+l */ +void linenoiseClearScreen(void) { + if (write(STDOUT_FILENO,"\x1b[H\x1b[2J",7) <= 0) { + /* nothing to do, just to avoid warning. */ + } +} + +/* Beep, used for completion when there is nothing to complete or when all + * the choices were already shown. */ +static void linenoiseBeep(void) { + fprintf(stderr, "\x7"); + fflush(stderr); +} + +/* ============================== Completion ================================ */ + +/* Free a list of completion option populated by linenoiseAddCompletion(). */ +static void freeCompletions(linenoiseCompletions *lc) { + size_t i; + for (i = 0; i < lc->len; i++) + free(lc->cvec[i]); + if (lc->cvec != NULL) + free(lc->cvec); +} + +/* This is an helper function for linenoiseEdit() and is called when the + * user types the <tab> key in order to complete the string currently in the + * input. + * + * The state of the editing is encapsulated into the pointed linenoiseState + * structure as described in the structure definition. */ +static int completeLine(struct linenoiseState *ls) { + linenoiseCompletions lc = { 0, NULL }; + int nread, nwritten; + char c = 0; + + completionCallback(ls->buf,&lc); + if (lc.len == 0) { + linenoiseBeep(); + } else { + size_t stop = 0, i = 0; + + while(!stop) { + /* Show completion or original buffer */ + if (i < lc.len) { + struct linenoiseState saved = *ls; + + ls->len = ls->pos = strlen(lc.cvec[i]); + ls->buf = lc.cvec[i]; + refreshLine(ls); + ls->len = saved.len; + ls->pos = saved.pos; + ls->buf = saved.buf; + } else { + refreshLine(ls); + } + + nread = read(ls->ifd,&c,1); + if (nread <= 0) { + freeCompletions(&lc); + return -1; + } + + switch(c) { + case 9: /* tab */ + i = (i+1) % (lc.len+1); + if (i == lc.len) linenoiseBeep(); + break; + case 27: /* escape */ + /* Re-show original buffer */ + if (i < lc.len) refreshLine(ls); + stop = 1; + break; + default: + /* Update buffer and return */ + if (i < lc.len) { + nwritten = snprintf(ls->buf,ls->buflen,"%s",lc.cvec[i]); + ls->len = ls->pos = nwritten; + } + stop = 1; + break; + } + } + } + + freeCompletions(&lc); + return c; /* Return last read character */ +} + +/* Register a callback function to be called for tab-completion. */ +void linenoiseSetCompletionCallback(linenoiseCompletionCallback *fn) { + completionCallback = fn; +} + +/* This function is used by the callback function registered by the user + * in order to add completion options given the input string when the + * user typed <tab>. See the example.c source code for a very easy to + * understand example. */ +void linenoiseAddCompletion(linenoiseCompletions *lc, const char *str) { + size_t len = strlen(str); + char *copy, **cvec; + + copy = malloc(len+1); + if (copy == NULL) return; + memcpy(copy,str,len+1); + cvec = realloc(lc->cvec,sizeof(char*)*(lc->len+1)); + if (cvec == NULL) { + free(copy); + return; + } + lc->cvec = cvec; + lc->cvec[lc->len++] = copy; +} + +/* =========================== Line editing ================================= */ + +/* We define a very simple "append buffer" structure, that is an heap + * allocated string where we can append to. This is useful in order to + * write all the escape sequences in a buffer and flush them to the standard + * output in a single call, to avoid flickering effects. */ +struct abuf { + char *b; + int len; +}; + +static void abInit(struct abuf *ab) { + ab->b = NULL; + ab->len = 0; +} + +static void abAppend(struct abuf *ab, const char *s, int len) { + char *new = realloc(ab->b,ab->len+len); + + if (new == NULL) return; + memcpy(new+ab->len,s,len); + ab->b = new; + ab->len += len; +} + +static void abFree(struct abuf *ab) { + free(ab->b); +} + +/* Single line low level line refresh. + * + * Rewrite the currently edited line accordingly to the buffer content, + * cursor position, and number of columns of the terminal. */ +static void refreshSingleLine(struct linenoiseState *l) { + char seq[64]; + size_t plen = strlen(l->prompt); + int fd = l->ofd; + char *buf = l->buf; + size_t len = l->len; + size_t pos = l->pos; + struct abuf ab; + + while((plen+pos) >= l->cols) { + buf++; + len--; + pos--; + } + while (plen+len > l->cols) { + len--; + } + + abInit(&ab); + /* Cursor to left edge */ + snprintf(seq,64,"\r"); + abAppend(&ab,seq,strlen(seq)); + /* Write the prompt and the current buffer content */ + abAppend(&ab,l->prompt,strlen(l->prompt)); + abAppend(&ab,buf,len); + /* Erase to right */ + snprintf(seq,64,"\x1b[0K"); + abAppend(&ab,seq,strlen(seq)); + /* Move cursor to original position. */ + snprintf(seq,64,"\r\x1b[%dC", (int)(pos+plen)); + abAppend(&ab,seq,strlen(seq)); + if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ + abFree(&ab); +} + +/* Multi line low level line refresh. + * + * Rewrite the currently edited line accordingly to the buffer content, + * cursor position, and number of columns of the terminal. */ +static void refreshMultiLine(struct linenoiseState *l) { + char seq[64]; + int plen = strlen(l->prompt); + int rows = (plen+l->len+l->cols-1)/l->cols; /* rows used by current buf. */ + int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */ + int rpos2; /* rpos after refresh. */ + int col; /* colum position, zero-based. */ + int old_rows = l->maxrows; + int fd = l->ofd, j; + struct abuf ab; + + /* Update maxrows if needed. */ + if (rows > (int)l->maxrows) l->maxrows = rows; + + /* First step: clear all the lines used before. To do so start by + * going to the last row. */ + abInit(&ab); + if (old_rows-rpos > 0) { + lndebug("go down %d", old_rows-rpos); + snprintf(seq,64,"\x1b[%dB", old_rows-rpos); + abAppend(&ab,seq,strlen(seq)); + } + + /* Now for every row clear it, go up. */ + for (j = 0; j < old_rows-1; j++) { + lndebug("clear+up"); + snprintf(seq,64,"\r\x1b[0K\x1b[1A"); + abAppend(&ab,seq,strlen(seq)); + } + + /* Clean the top line. */ + lndebug("clear"); + snprintf(seq,64,"\r\x1b[0K"); + abAppend(&ab,seq,strlen(seq)); + + /* Write the prompt and the current buffer content */ + abAppend(&ab,l->prompt,strlen(l->prompt)); + abAppend(&ab,l->buf,l->len); + + /* If we are at the very end of the screen with our prompt, we need to + * emit a newline and move the prompt to the first column. */ + if (l->pos && + l->pos == l->len && + (l->pos+plen) % l->cols == 0) + { + lndebug("<newline>"); + abAppend(&ab,"\n",1); + snprintf(seq,64,"\r"); + abAppend(&ab,seq,strlen(seq)); + rows++; + if (rows > (int)l->maxrows) l->maxrows = rows; + } + + /* Move cursor to right position. */ + rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ + lndebug("rpos2 %d", rpos2); + + /* Go up till we reach the expected positon. */ + if (rows-rpos2 > 0) { + lndebug("go-up %d", rows-rpos2); + snprintf(seq,64,"\x1b[%dA", rows-rpos2); + abAppend(&ab,seq,strlen(seq)); + } + + /* Set column. */ + col = (plen+(int)l->pos) % (int)l->cols; + lndebug("set col %d", 1+col); + if (col) + snprintf(seq,64,"\r\x1b[%dC", col); + else + snprintf(seq,64,"\r"); + abAppend(&ab,seq,strlen(seq)); + + lndebug("\n"); + l->oldpos = l->pos; + + if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ + abFree(&ab); +} + +/* Calls the two low level functions refreshSingleLine() or + * refreshMultiLine() according to the selected mode. */ +static void refreshLine(struct linenoiseState *l) { + if (mlmode) + refreshMultiLine(l); + else + refreshSingleLine(l); +} + +/* Insert the character 'c' at cursor current position. + * + * On error writing to the terminal -1 is returned, otherwise 0. */ +int linenoiseEditInsert(struct linenoiseState *l, char c) { + if (l->len < l->buflen) { + if (l->len == l->pos) { + l->buf[l->pos] = c; + l->pos++; + l->len++; + l->buf[l->len] = '\0'; + if ((!mlmode && l->plen+l->len < l->cols) /* || mlmode */) { + /* Avoid a full update of the line in the + * trivial case. */ + if (write(l->ofd,&c,1) == -1) return -1; + } else { + refreshLine(l); + } + } else { + memmove(l->buf+l->pos+1,l->buf+l->pos,l->len-l->pos); + l->buf[l->pos] = c; + l->len++; + l->pos++; + l->buf[l->len] = '\0'; + refreshLine(l); + } + } + return 0; +} + +/* Move cursor on the left. */ +void linenoiseEditMoveLeft(struct linenoiseState *l) { + if (l->pos > 0) { + l->pos--; + refreshLine(l); + } +} + +/* Move cursor on the right. */ +void linenoiseEditMoveRight(struct linenoiseState *l) { + if (l->pos != l->len) { + l->pos++; + refreshLine(l); + } +} + +/* Move cursor to the start of the line. */ +void linenoiseEditMoveHome(struct linenoiseState *l) { + if (l->pos != 0) { + l->pos = 0; + refreshLine(l); + } +} + +/* Move cursor to the end of the line. */ +void linenoiseEditMoveEnd(struct linenoiseState *l) { + if (l->pos != l->len) { + l->pos = l->len; + refreshLine(l); + } +} + +/* Substitute the currently edited line with the next or previous history + * entry as specified by 'dir'. */ +#define LINENOISE_HISTORY_NEXT 0 +#define LINENOISE_HISTORY_PREV 1 +void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) { + if (history_len > 1) { + /* Update the current history entry before to + * overwrite it with the next one. */ + free(history[history_len - 1 - l->history_index]); + history[history_len - 1 - l->history_index] = strdup(l->buf); + /* Show the new entry */ + l->history_index += (dir == LINENOISE_HISTORY_PREV) ? 1 : -1; + if (l->history_index < 0) { + l->history_index = 0; + return; + } else if (l->history_index >= history_len) { + l->history_index = history_len-1; + return; + } + strncpy(l->buf,history[history_len - 1 - l->history_index],l->buflen); + l->buf[l->buflen-1] = '\0'; + l->len = l->pos = strlen(l->buf); + refreshLine(l); + } +} + +/* Delete the character at the right of the cursor without altering the cursor + * position. Basically this is what happens with the "Delete" keyboard key. */ +void linenoiseEditDelete(struct linenoiseState *l) { + if (l->len > 0 && l->pos < l->len) { + memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1); + l->len--; + l->buf[l->len] = '\0'; + refreshLine(l); + } +} + +/* Backspace implementation. */ +void linenoiseEditBackspace(struct linenoiseState *l) { + if (l->pos > 0 && l->len > 0) { + memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos); + l->pos--; + l->len--; + l->buf[l->len] = '\0'; + refreshLine(l); + } +} + +/* Delete the previosu word, maintaining the cursor at the start of the + * current word. */ +void linenoiseEditDeletePrevWord(struct linenoiseState *l) { + size_t old_pos = l->pos; + size_t diff; + + while (l->pos > 0 && l->buf[l->pos-1] == ' ') + l->pos--; + while (l->pos > 0 && l->buf[l->pos-1] != ' ') + l->pos--; + diff = old_pos - l->pos; + memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1); + l->len -= diff; + refreshLine(l); +} + +/* This function is the core of the line editing capability of linenoise. + * It expects 'fd' to be already in "raw mode" so that every key pressed + * will be returned ASAP to read(). + * + * The resulting string is put into 'buf' when the user type enter, or + * when ctrl+d is typed. + * + * The function returns the length of the current buffer. */ +static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt) +{ + struct linenoiseState l; + + /* Populate the linenoise state that we pass to functions implementing + * specific editing functionalities. */ + l.ifd = stdin_fd; + l.ofd = stdout_fd; + l.buf = buf; + l.buflen = buflen; + l.prompt = prompt; + l.plen = strlen(prompt); + l.oldpos = l.pos = 0; + l.len = 0; + l.cols = getColumns(stdin_fd, stdout_fd); + l.maxrows = 0; + l.history_index = 0; + + /* Buffer starts empty. */ + l.buf[0] = '\0'; + l.buflen--; /* Make sure there is always space for the nulterm */ + + /* The latest history entry is always our current buffer, that + * initially is just an empty string. */ + linenoiseHistoryAdd(""); + + if (write(l.ofd,prompt,l.plen) == -1) return -1; + while(1) { + char c; + int nread; + char seq[3]; + + nread = read(l.ifd,&c,1); + if (nread <= 0) return l.len; + + /* Only autocomplete when the callback is set. It returns < 0 when + * there was an error reading from fd. Otherwise it will return the + * character that should be handled next. */ + if (c == 9 && completionCallback != NULL) { + c = completeLine(&l); + /* Return on errors */ + if (c < 0) return l.len; + /* Read next character when 0 */ + if (c == 0) continue; + } + + switch(c) { + case ENTER: /* enter */ + history_len--; + free(history[history_len]); + if (mlmode) linenoiseEditMoveEnd(&l); + return (int)l.len; + case CTRL_C: /* ctrl-c */ + errno = EAGAIN; + return -1; + case BACKSPACE: /* backspace */ + case 8: /* ctrl-h */ + linenoiseEditBackspace(&l); + break; + case CTRL_D: /* ctrl-d, remove char at right of cursor, or if the + line is empty, act as end-of-file. */ + if (l.len > 0) { + linenoiseEditDelete(&l); + } else { + history_len--; + free(history[history_len]); + return -1; + } + break; + case CTRL_T: /* ctrl-t, swaps current character with previous. */ + if (l.pos > 0 && l.pos < l.len) { + int aux = buf[l.pos-1]; + buf[l.pos-1] = buf[l.pos]; + buf[l.pos] = aux; + if (l.pos != l.len-1) l.pos++; + refreshLine(&l); + } + break; + case CTRL_B: /* ctrl-b */ + linenoiseEditMoveLeft(&l); + break; + case CTRL_F: /* ctrl-f */ + linenoiseEditMoveRight(&l); + break; + case CTRL_P: /* ctrl-p */ + linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_PREV); + break; + case CTRL_N: /* ctrl-n */ + linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_NEXT); + break; + case ESC: /* escape sequence */ + /* Read the next two bytes representing the escape sequence. + * Use two calls to handle slow terminals returning the two + * chars at different times. */ + if (read(l.ifd,seq,1) == -1) break; + if (read(l.ifd,seq+1,1) == -1) break; + + /* ESC [ sequences. */ + if (seq[0] == '[') { + if (seq[1] >= '0' && seq[1] <= '9') { + /* Extended escape, read additional byte. */ + if (read(l.ifd,seq+2,1) == -1) break; + if (seq[2] == '~') { + switch(seq[1]) { + case '3': /* Delete key. */ + linenoiseEditDelete(&l); + break; + } + } + } else { + switch(seq[1]) { + case 'A': /* Up */ + linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_PREV); + break; + case 'B': /* Down */ + linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_NEXT); + break; + case 'C': /* Right */ + linenoiseEditMoveRight(&l); + break; + case 'D': /* Left */ + linenoiseEditMoveLeft(&l); + break; + case 'H': /* Home */ + linenoiseEditMoveHome(&l); + break; + case 'F': /* End*/ + linenoiseEditMoveEnd(&l); + break; + } + } + } + + /* ESC O sequences. */ + else if (seq[0] == 'O') { + switch(seq[1]) { + case 'H': /* Home */ + linenoiseEditMoveHome(&l); + break; + case 'F': /* End*/ + linenoiseEditMoveEnd(&l); + break; + } + } + break; + default: + if (linenoiseEditInsert(&l,c)) return -1; + break; + case CTRL_U: /* Ctrl+u, delete the whole line. */ + buf[0] = '\0'; + l.pos = l.len = 0; + refreshLine(&l); + break; + case CTRL_K: /* Ctrl+k, delete from current to end of line. */ + buf[l.pos] = '\0'; + l.len = l.pos; + refreshLine(&l); + break; + case CTRL_A: /* Ctrl+a, go to the start of the line */ + linenoiseEditMoveHome(&l); + break; + case CTRL_E: /* ctrl+e, go to the end of the line */ + linenoiseEditMoveEnd(&l); + break; + case CTRL_L: /* ctrl+l, clear screen */ + linenoiseClearScreen(); + refreshLine(&l); + break; + case CTRL_W: /* ctrl+w, delete previous word */ + linenoiseEditDeletePrevWord(&l); + break; + } + } + return l.len; +} + +/* This special mode is used by linenoise in order to print scan codes + * on screen for debugging / development purposes. It is implemented + * by the linenoise_example program using the --keycodes option. */ +void linenoisePrintKeyCodes(void) { + char quit[4]; + + printf("Linenoise key codes debugging mode.\n" + "Press keys to see scan codes. Type 'quit' at any time to exit.\n"); + if (enableRawMode(STDIN_FILENO) == -1) return; + memset(quit,' ',4); + while(1) { + char c; + int nread; + + nread = read(STDIN_FILENO,&c,1); + if (nread <= 0) continue; + memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */ + quit[sizeof(quit)-1] = c; /* Insert current char on the right. */ + if (memcmp(quit,"quit",sizeof(quit)) == 0) break; + + printf("'%c' %02x (%d) (type quit to exit)\n", + isprint(c) ? c : '?', (int)c, (int)c); + printf("\r"); /* Go left edge manually, we are in raw mode. */ + fflush(stdout); + } + disableRawMode(STDIN_FILENO); +} + +/* This function calls the line editing function linenoiseEdit() using + * the STDIN file descriptor set in raw mode. */ +static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) { + int count; + + if (buflen == 0) { + errno = EINVAL; + return -1; + } + if (!isatty(STDIN_FILENO)) { + /* Not a tty: read from file / pipe. */ + if (fgets(buf, buflen, stdin) == NULL) return -1; + count = strlen(buf); + if (count && buf[count-1] == '\n') { + count--; + buf[count] = '\0'; + } + } else { + /* Interactive editing. */ + if (enableRawMode(STDIN_FILENO) == -1) return -1; + count = linenoiseEdit(STDIN_FILENO, STDOUT_FILENO, buf, buflen, prompt); + disableRawMode(STDIN_FILENO); + printf("\n"); + } + return count; +} + +/* The high level function that is the main API of the linenoise library. + * This function checks if the terminal has basic capabilities, just checking + * for a blacklist of stupid terminals, and later either calls the line + * editing function or uses dummy fgets() so that you will be able to type + * something even in the most desperate of the conditions. */ +char *linenoise(const char *prompt) { + char buf[LINENOISE_MAX_LINE]; + int count; + + if (isUnsupportedTerm()) { + size_t len; + + printf("%s",prompt); + fflush(stdout); + if (fgets(buf,LINENOISE_MAX_LINE,stdin) == NULL) return NULL; + len = strlen(buf); + while(len && (buf[len-1] == '\n' || buf[len-1] == '\r')) { + len--; + buf[len] = '\0'; + } + return strdup(buf); + } else { + count = linenoiseRaw(buf,LINENOISE_MAX_LINE,prompt); + if (count == -1) return NULL; + return strdup(buf); + } +} + +/* ================================ History ================================= */ + +/* Free the history, but does not reset it. Only used when we have to + * exit() to avoid memory leaks are reported by valgrind & co. */ +static void freeHistory(void) { + if (history) { + int j; + + for (j = 0; j < history_len; j++) + free(history[j]); + free(history); + } +} + +/* At exit we'll try to fix the terminal to the initial conditions. */ +static void linenoiseAtExit(void) { + disableRawMode(STDIN_FILENO); + freeHistory(); +} + +/* This is the API call to add a new entry in the linenoise history. + * It uses a fixed array of char pointers that are shifted (memmoved) + * when the history max length is reached in order to remove the older + * entry and make room for the new one, so it is not exactly suitable for huge + * histories, but will work well for a few hundred of entries. + * + * Using a circular buffer is smarter, but a bit more complex to handle. */ +int linenoiseHistoryAdd(const char *line) { + char *linecopy; + + if (history_max_len == 0) return 0; + + /* Initialization on first call. */ + if (history == NULL) { + history = malloc(sizeof(char*)*history_max_len); + if (history == NULL) return 0; + memset(history,0,(sizeof(char*)*history_max_len)); + } + + /* Don't add duplicated lines. */ + if (history_len && !strcmp(history[history_len-1], line)) return 0; + + /* Add an heap allocated copy of the line in the history. + * If we reached the max length, remove the older line. */ + linecopy = strdup(line); + if (!linecopy) return 0; + if (history_len == history_max_len) { + free(history[0]); + memmove(history,history+1,sizeof(char*)*(history_max_len-1)); + history_len--; + } + history[history_len] = linecopy; + history_len++; + return 1; +} + +/* Set the maximum length for the history. This function can be called even + * if there is already some history, the function will make sure to retain + * just the latest 'len' elements if the new history length value is smaller + * than the amount of items already inside the history. */ +int linenoiseHistorySetMaxLen(int len) { + char **new; + + if (len < 1) return 0; + if (history) { + int tocopy = history_len; + + new = malloc(sizeof(char*)*len); + if (new == NULL) return 0; + + /* If we can't copy everything, free the elements we'll not use. */ + if (len < tocopy) { + int j; + + for (j = 0; j < tocopy-len; j++) free(history[j]); + tocopy = len; + } + memset(new,0,sizeof(char*)*len); + memcpy(new,history+(history_len-tocopy), sizeof(char*)*tocopy); + free(history); + history = new; + } + history_max_len = len; + if (history_len > history_max_len) + history_len = history_max_len; + return 1; +} + +/* Save the history in the specified file. On success 0 is returned + * otherwise -1 is returned. */ +int linenoiseHistorySave(const char *filename) { + FILE *fp = fopen(filename,"w"); + int j; + + if (fp == NULL) return -1; + for (j = 0; j < history_len; j++) + fprintf(fp,"%s\n",history[j]); + fclose(fp); + return 0; +} + +/* Load the history from the specified file. If the file does not exist + * zero is returned and no operation is performed. + * + * If the file exists and the operation succeeded 0 is returned, otherwise + * on error -1 is returned. */ +int linenoiseHistoryLoad(const char *filename) { + FILE *fp = fopen(filename,"r"); + char buf[LINENOISE_MAX_LINE]; + + if (fp == NULL) return -1; + + while (fgets(buf,LINENOISE_MAX_LINE,fp) != NULL) { + char *p; + + p = strchr(buf,'\r'); + if (!p) p = strchr(buf,'\n'); + if (p) *p = '\0'; + linenoiseHistoryAdd(buf); + } + fclose(fp); + return 0; +} diff --git a/lib/wrappers/linenoise/clinenoise.h b/lib/wrappers/linenoise/clinenoise.h new file mode 100644 index 000000000..fbb01cfaa --- /dev/null +++ b/lib/wrappers/linenoise/clinenoise.h @@ -0,0 +1,68 @@ +/* linenoise.h -- VERSION 1.0 + * + * Guerrilla line editing library against the idea that a line editing lib + * needs to be 20,000 lines of C code. + * + * See linenoise.c for more information. + * + * ------------------------------------------------------------------------ + * + * Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com> + * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com> + * + * 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. + * + * 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 + * HOLDER 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. + */ + +#ifndef __LINENOISE_H +#define __LINENOISE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct linenoiseCompletions { + size_t len; + char **cvec; +} linenoiseCompletions; + +typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *); +void linenoiseSetCompletionCallback(linenoiseCompletionCallback *); +void linenoiseAddCompletion(linenoiseCompletions *, const char *); + +char *linenoise(const char *prompt); +int linenoiseHistoryAdd(const char *line); +int linenoiseHistorySetMaxLen(int len); +int linenoiseHistorySave(const char *filename); +int linenoiseHistoryLoad(const char *filename); +void linenoiseClearScreen(void); +void linenoiseSetMultiLine(int ml); +void linenoisePrintKeyCodes(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __LINENOISE_H */ diff --git a/lib/wrappers/linenoise/linenoise.nim b/lib/wrappers/linenoise/linenoise.nim new file mode 100644 index 000000000..b7004c6e2 --- /dev/null +++ b/lib/wrappers/linenoise/linenoise.nim @@ -0,0 +1,34 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +type + Completions* = object + len*: csize + cvec*: cstringArray + + CompletionCallback* = proc (a2: cstring; a3: ptr Completions) {.cdecl.} + +{.compile: "clinenoise.c".} + +proc setCompletionCallback*(a2: ptr CompletionCallback) {. + importc: "linenoiseSetCompletionCallback".} +proc addCompletion*(a2: ptr Completions; a3: cstring) {. + importc: "linenoiseAddCompletion".} +proc readLine*(prompt: cstring): cstring {.importc: "linenoise".} +proc historyAdd*(line: cstring): cint {.importc: "linenoiseHistoryAdd", + discardable.} +proc historySetMaxLen*(len: cint): cint {.importc: "linenoiseHistorySetMaxLen".} +proc historySave*(filename: cstring): cint {.importc: "linenoiseHistorySave".} +proc historyLoad*(filename: cstring): cint {.importc: "linenoiseHistoryLoad".} +proc clearScreen*() {.importc: "linenoiseClearScreen".} +proc setMultiLine*(ml: cint) {.importc: "linenoiseSetMultiLine".} +proc printKeyCodes*() {.importc: "linenoisePrintKeyCodes".} + +proc free*(s: cstring) {.importc: "free", header: "<stdlib.h>".} + diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 937a8952a..73b82b5c6 100644 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -51,7 +51,7 @@ const SERVICENAME* = "MySQL" type - Tenum_server_command* = enum + Enum_server_command* = enum COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, COM_TIME, @@ -59,6 +59,7 @@ type COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_END +{.deprecated: [Tenum_server_command: Enum_server_command].} const SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake; @@ -150,8 +151,8 @@ const MAX_BLOB_WIDTH* = 8192 # Default width for blob type - Pst_net* = ptr Tst_net - Tst_net*{.final.} = object + Pst_net* = ptr St_net + St_net*{.final.} = object vio*: PVio buff*: cstring buff_end*: cstring @@ -191,14 +192,15 @@ type report_error*: my_bool # We should report error (we have unreported error) return_errno*: my_bool - TNET* = Tst_net - PNET* = ptr TNET + NET* = St_net + PNET* = ptr NET +{.deprecated: [Tst_net: St_net, TNET: NET].} const packet_error* = - 1 type - Tenum_field_types* = enum # For backward compatibility + Enum_field_types* = enum # For backward compatibility TYPE_DECIMAL, TYPE_TINY, TYPE_SHORT, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_NULL, TYPE_TIMESTAMP, TYPE_LONGLONG, TYPE_INT24, TYPE_DATE, TYPE_TIME, TYPE_DATETIME, TYPE_YEAR, TYPE_NEWDATE, TYPE_VARCHAR, TYPE_BIT, @@ -206,6 +208,7 @@ type TYPE_TINY_BLOB = 249, TYPE_MEDIUM_BLOB = 250, TYPE_LONG_BLOB = 251, TYPE_BLOB = 252, TYPE_VAR_STRING = 253, TYPE_STRING = 254, TYPE_GEOMETRY = 255 +{.deprecated: [Tenum_field_types: Enum_field_types].} const CLIENT_MULTI_QUERIES* = CLIENT_MULTI_STATEMENTS @@ -244,16 +247,19 @@ const SHUTDOWN_KILLABLE_UPDATE* = chr(1 shl 3) type - Tenum_shutdown_level* = enum + Enum_shutdown_level* = enum SHUTDOWN_DEFAULT = 0, SHUTDOWN_WAIT_CONNECTIONS = 1, SHUTDOWN_WAIT_TRANSACTIONS = 2, SHUTDOWN_WAIT_UPDATES = 8, SHUTDOWN_WAIT_ALL_BUFFERS = 16, SHUTDOWN_WAIT_CRITICAL_BUFFERS = 17, KILL_QUERY = 254, KILL_CONNECTION = 255 - Tenum_cursor_type* = enum # options for mysql_set_option + Enum_cursor_type* = enum # options for mysql_set_option CURSOR_TYPE_NO_CURSOR = 0, CURSOR_TYPE_READ_ONLY = 1, CURSOR_TYPE_FOR_UPDATE = 2, CURSOR_TYPE_SCROLLABLE = 4 - Tenum_mysql_set_option* = enum + Enum_mysql_set_option* = enum OPTION_MULTI_STATEMENTS_ON, OPTION_MULTI_STATEMENTS_OFF +{.deprecated: [Tenum_shutdown_level: Enum_shutdown_level, + Tenum_cursor_type: Enum_cursor_type, + Tenum_mysql_set_option: Enum_mysql_set_option].} proc my_net_init*(net: PNET, vio: PVio): my_bool{.cdecl, dynlib: lib, importc: "my_net_init".} @@ -275,24 +281,25 @@ proc my_net_read*(net: PNET): int{.cdecl, dynlib: lib, importc: "my_net_read".} # The following function is not meant for normal usage # Currently it's used internally by manager.c type - Psockaddr* = ptr Tsockaddr - Tsockaddr*{.final.} = object # undefined structure + Psockaddr* = ptr Sockaddr + Sockaddr*{.final.} = object # undefined structure +{.deprecated: [Tsockaddr: Sockaddr].} proc my_connect*(s: my_socket, name: Psockaddr, namelen: cuint, timeout: cuint): cint{. cdecl, dynlib: lib, importc: "my_connect".} type - Prand_struct* = ptr Trand_struct - Trand_struct*{.final.} = object # The following is for user defined functions + Prand_struct* = ptr Rand_struct + Rand_struct*{.final.} = object # The following is for user defined functions seed1*: int seed2*: int max_value*: int max_value_dbl*: cdouble - TItem_result* = enum + Item_result* = enum STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT - PItem_result* = ptr TItem_result - Pst_udf_args* = ptr Tst_udf_args - Tst_udf_args*{.final.} = object + PItem_result* = ptr Item_result + Pst_udf_args* = ptr St_udf_args + St_udf_args*{.final.} = object arg_count*: cuint # Number of arguments arg_type*: PItem_result # Pointer to item_results args*: cstringArray # Pointer to item_results @@ -301,18 +308,21 @@ type attributes*: cstringArray # Pointer to attribute name attribute_lengths*: ptr int # Length of attribute arguments - TUDF_ARGS* = Tst_udf_args - PUDF_ARGS* = ptr TUDF_ARGS # This holds information about the result - Pst_udf_init* = ptr Tst_udf_init - Tst_udf_init*{.final.} = object + UDF_ARGS* = St_udf_args + PUDF_ARGS* = ptr UDF_ARGS # This holds information about the result + Pst_udf_init* = ptr St_udf_init + St_udf_init*{.final.} = object maybe_null*: my_bool # 1 if function can return NULL decimals*: cuint # for real functions max_length*: int # For string functions theptr*: cstring # free pointer for function data const_item*: my_bool # free pointer for function data - TUDF_INIT* = Tst_udf_init - PUDF_INIT* = ptr TUDF_INIT # Constants when using compression + UDF_INIT* = St_udf_init + PUDF_INIT* = ptr UDF_INIT # Constants when using compression +{.deprecated: [Trand_stuct: Rand_struct, TItem_result: Item_result, + Tst_udf_args: St_udf_args, TUDF_ARGS: UDF_ARGS, + Tst_udf_init: St_udf_init, TUDF_INIT: UDF_INIT].} const NET_HEADER_SIZE* = 4 # standard header size @@ -386,8 +396,8 @@ const CLIENT_NET_WRITE_TIMEOUT* = 365 * 24 * 3600 # Timeout on write type - Pst_mysql_field* = ptr Tst_mysql_field - Tst_mysql_field*{.final.} = object + Pst_mysql_field* = ptr St_mysql_field + St_mysql_field*{.final.} = object name*: cstring # Name of column org_name*: cstring # Original column name, if an alias table*: cstring # Table of column if column was a field @@ -407,19 +417,21 @@ type flags*: cuint # Div flags decimals*: cuint # Number of decimals in field charsetnr*: cuint # Character set - ftype*: Tenum_field_types # Type of field. See mysql_com.h for types + ftype*: Enum_field_types # Type of field. See mysql_com.h for types - TFIELD* = Tst_mysql_field - PFIELD* = ptr TFIELD - PROW* = ptr TROW # return data as array of strings - TROW* = cstringArray - PFIELD_OFFSET* = ptr TFIELD_OFFSET # offset to current field - TFIELD_OFFSET* = cuint + FIELD* = St_mysql_field + PFIELD* = ptr FIELD + PROW* = ptr ROW # return data as array of strings + ROW* = cstringArray + PFIELD_OFFSET* = ptr FIELD_OFFSET # offset to current field + FIELD_OFFSET* = cuint +{.deprecated: [Tst_mysql_field: St_mysql_field, TFIELD: FIELD, TROW: ROW, + TFIELD_OFFSET: FIELD_OFFSET].} proc IS_PRI_KEY*(n: int32): bool proc IS_NOT_NULL*(n: int32): bool proc IS_BLOB*(n: int32): bool -proc IS_NUM*(t: Tenum_field_types): bool +proc IS_NUM*(t: Enum_field_types): bool proc INTERNAL_NUM_FIELD*(f: Pst_mysql_field): bool proc IS_NUM_FIELD*(f: Pst_mysql_field): bool type @@ -430,32 +442,34 @@ const COUNT_ERROR* = not (my_ulonglong(0)) type - Pst_mysql_rows* = ptr Tst_mysql_rows - Tst_mysql_rows*{.final.} = object + Pst_mysql_rows* = ptr St_mysql_rows + St_mysql_rows*{.final.} = object next*: Pst_mysql_rows # list of rows - data*: TROW + data*: ROW len*: int - TROWS* = Tst_mysql_rows - PROWS* = ptr TROWS - PROW_OFFSET* = ptr TROW_OFFSET # offset to current row - TROW_OFFSET* = TROWS + ROWS* = St_mysql_rows + PROWS* = ptr ROWS + PROW_OFFSET* = ptr ROW_OFFSET # offset to current row + ROW_OFFSET* = ROWS +{.deprecated: [Tst_mysql_rows: St_mysql_rows, TROWS: ROWS, + TROW_OFFSET: ROW_OFFSET].} const ALLOC_MAX_BLOCK_TO_DROP* = 4096 ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP* = 10 # struct for once_alloc (block) type - Pst_used_mem* = ptr Tst_used_mem - Tst_used_mem*{.final.} = object + Pst_used_mem* = ptr St_used_mem + St_used_mem*{.final.} = object next*: Pst_used_mem # Next block in use left*: cuint # memory left in block size*: cuint # size of block - TUSED_MEM* = Tst_used_mem - PUSED_MEM* = ptr TUSED_MEM - Pst_mem_root* = ptr Tst_mem_root - Tst_mem_root*{.final.} = object + USED_MEM* = St_used_mem + PUSED_MEM* = ptr USED_MEM + Pst_mem_root* = ptr St_mem_root + St_mem_root*{.final.} = object free*: PUSED_MEM # blocks with free memory in it used*: PUSED_MEM # blocks almost without free memory pre_alloc*: PUSED_MEM # preallocated block @@ -467,27 +481,30 @@ type first_block_usage*: cuint error_handler*: proc (){.cdecl.} - TMEM_ROOT* = Tst_mem_root - PMEM_ROOT* = ptr TMEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- + MEM_ROOT* = St_mem_root + PMEM_ROOT* = ptr MEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- +{.deprecated: [Tst_used_mem: St_used_mem, TUSED_MEM: USED_MEM, + Tst_mem_root: St_mem_root, TMEM_ROOT: MEM_ROOT].} type - Pst_mysql_data* = ptr Tst_mysql_data - Tst_mysql_data*{.final.} = object + Pst_mysql_data* = ptr St_mysql_data + St_mysql_data*{.final.} = object rows*: my_ulonglong fields*: cuint data*: PROWS - alloc*: TMEM_ROOT + alloc*: MEM_ROOT prev_ptr*: ptr PROWS - TDATA* = Tst_mysql_data - PDATA* = ptr TDATA - Toption* = enum + DATA* = St_mysql_data + PDATA* = ptr DATA + Option* = enum OPT_CONNECT_TIMEOUT, OPT_COMPRESS, OPT_NAMED_PIPE, INIT_COMMAND, READ_DEFAULT_FILE, READ_DEFAULT_GROUP, SET_CHARSET_DIR, SET_CHARSET_NAME, OPT_LOCAL_INFILE, OPT_PROTOCOL, SHARED_MEMORY_BASE_NAME, OPT_READ_TIMEOUT, OPT_WRITE_TIMEOUT, OPT_USE_RESULT, OPT_USE_REMOTE_CONNECTION, OPT_USE_EMBEDDED_CONNECTION, OPT_GUESS_CONNECTION, SET_CLIENT_IP, SECURE_AUTH, REPORT_DATA_TRUNCATION, OPT_RECONNECT +{.deprecated: [Tst_mysql_data: St_mysql_data, TDATA: DATA, Toption: Option].} const MAX_MYSQL_MANAGER_ERR* = 256 @@ -499,17 +516,17 @@ const MANAGER_INTERNAL_ERR* = 500 type - Tst_dynamic_array*{.final.} = object + St_dynamic_array*{.final.} = object buffer*: cstring elements*: cuint max_element*: cuint alloc_increment*: cuint size_of_element*: cuint - TDYNAMIC_ARRAY* = Tst_dynamic_array - Pst_dynamic_array* = ptr Tst_dynamic_array - Pst_mysql_options* = ptr Tst_mysql_options - Tst_mysql_options*{.final.} = object + DYNAMIC_ARRAY* = St_dynamic_array + Pst_dynamic_array* = ptr St_dynamic_array + Pst_mysql_options* = ptr St_mysql_options + St_mysql_options*{.final.} = object connect_timeout*: cuint read_timeout*: cuint write_timeout*: cuint @@ -543,7 +560,7 @@ type # a read that is replication-aware no_master_reads*: my_bool separate_thread*: my_bool - methods_to_use*: Toption + methods_to_use*: Option client_ip*: cstring secure_auth*: my_bool # Refuse client connecting to server if it uses old (pre-4.1.1) protocol report_data_truncation*: my_bool # 0 - never report, 1 - always report (default) @@ -555,16 +572,16 @@ type local_infile_error*: proc (para1: pointer, para2: cstring, para3: cuint): cint local_infile_userdata*: pointer - Tstatus* = enum + Status* = enum STATUS_READY, STATUS_GET_RESULT, STATUS_USE_RESULT - Tprotocol_type* = enum # There are three types of queries - the ones that have to go to + Protocol_type* = enum # There are three types of queries - the ones that have to go to # the master, the ones that go to a slave, and the administrative # type which must happen on the pivot connectioin PROTOCOL_DEFAULT, PROTOCOL_TCP, PROTOCOL_SOCKET, PROTOCOL_PIPE, PROTOCOL_MEMORY - Trpl_type* = enum + Rpl_type* = enum RPL_MASTER, RPL_SLAVE, RPL_ADMIN - Tcharset_info_st*{.final.} = object + Charset_info_st*{.final.} = object number*: cuint primary_number*: cuint binary_number*: cuint @@ -592,10 +609,10 @@ type cset*: pointer # was ^MY_CHARSET_HANDLER coll*: pointer # was ^MY_COLLATION_HANDLER; - TCHARSET_INFO* = Tcharset_info_st - Pcharset_info_st* = ptr Tcharset_info_st - Pcharacter_set* = ptr Tcharacter_set - Tcharacter_set*{.final.} = object + CHARSET_INFO* = Charset_info_st + Pcharset_info_st* = ptr Charset_info_st + Pcharacter_set* = ptr Character_set + Character_set*{.final.} = object number*: cuint state*: cuint csname*: cstring @@ -605,12 +622,12 @@ type mbminlen*: cuint mbmaxlen*: cuint - TMY_CHARSET_INFO* = Tcharacter_set - PMY_CHARSET_INFO* = ptr TMY_CHARSET_INFO - Pst_mysql_methods* = ptr Tst_mysql_methods - Pst_mysql* = ptr Tst_mysql - Tst_mysql*{.final.} = object - net*: TNET # Communication parameters + MY_CHARSET_INFO* = Character_set + PMY_CHARSET_INFO* = ptr MY_CHARSET_INFO + Pst_mysql_methods* = ptr St_mysql_methods + Pst_mysql* = ptr St_mysql + St_mysql*{.final.} = object + net*: NET # Communication parameters connector_fd*: gptr # ConnectorFd for SSL host*: cstring user*: cstring @@ -622,7 +639,7 @@ type db*: cstring charset*: Pcharset_info_st fields*: PFIELD - field_alloc*: TMEM_ROOT + field_alloc*: MEM_ROOT affected_rows*: my_ulonglong insert_id*: my_ulonglong # id if insert on table with NEXTNR extra_info*: my_ulonglong # Used by mysqlshow, not used by mysql 5.0 and up @@ -636,8 +653,8 @@ type server_status*: cuint server_language*: cuint warning_count*: cuint - options*: Tst_mysql_options - status*: Tstatus + options*: St_mysql_options + status*: Status free_me*: my_bool # If free in mysql_close reconnect*: my_bool # set to 1 if automatic reconnect scramble*: array[0..(SCRAMBLE_LENGTH + 1) - 1, char] # session-wide random string @@ -655,37 +672,37 @@ type # from mysql_stmt_close if close had to cancel result set of this object. unbuffered_fetch_owner*: Pmy_bool - TMySQL* = Tst_mysql - PMySQL* = ptr TMySQL - Pst_mysql_res* = ptr Tst_mysql_res - Tst_mysql_res*{.final.} = object + MySQL* = St_mysql + PMySQL* = ptr MySQL + Pst_mysql_res* = ptr St_mysql_res + St_mysql_res*{.final.} = object row_count*: my_ulonglong fields*: PFIELD data*: PDATA data_cursor*: PROWS lengths*: ptr int # column lengths of current row handle*: PMySQL # for unbuffered reads - field_alloc*: TMEM_ROOT + field_alloc*: MEM_ROOT field_count*: cuint current_field*: cuint - row*: TROW # If unbuffered read - current_row*: TROW # buffer to current row + row*: ROW # If unbuffered read + current_row*: ROW # buffer to current row eof*: my_bool # Used by mysql_fetch_row unbuffered_fetch_cancelled*: my_bool # mysql_stmt_close() had to cancel this result methods*: Pst_mysql_methods - TRES* = Tst_mysql_res - PRES* = ptr TRES - Pst_mysql_stmt* = ptr Tst_mysql_stmt - PSTMT* = ptr TSTMT - Tst_mysql_methods*{.final.} = object + RES* = St_mysql_res + PRES* = ptr RES + Pst_mysql_stmt* = ptr St_mysql_stmt + PSTMT* = ptr STMT + St_mysql_methods*{.final.} = object read_query_result*: proc (MySQL: PMySQL): my_bool{.cdecl.} - advanced_command*: proc (MySQL: PMySQL, command: Tenum_server_command, header: cstring, + advanced_command*: proc (MySQL: PMySQL, command: Enum_server_command, header: cstring, header_length: int, arg: cstring, arg_length: int, skip_check: my_bool): my_bool read_rows*: proc (MySQL: PMySQL, fields: PFIELD, fields_count: cuint): PDATA use_result*: proc (MySQL: PMySQL): PRES - fetch_lengths*: proc (fto: ptr int, column: TROW, field_count: cuint) + fetch_lengths*: proc (fto: ptr int, column: ROW, field_count: cuint) flush_use_result*: proc (MySQL: PMySQL) list_fields*: proc (MySQL: PMySQL): PFIELD read_prepare_result*: proc (MySQL: PMySQL, stmt: PSTMT): my_bool @@ -698,11 +715,11 @@ type read_change_user_result*: proc (MySQL: PMySQL, buff: cstring, passwd: cstring): cint read_rowsfrom_cursor*: proc (stmt: PSTMT): cint - TMETHODS* = Tst_mysql_methods - PMETHODS* = ptr TMETHODS - Pst_mysql_manager* = ptr Tst_mysql_manager - Tst_mysql_manager*{.final.} = object - net*: TNET + METHODS* = St_mysql_methods + PMETHODS* = ptr METHODS + Pst_mysql_manager* = ptr St_mysql_manager + St_mysql_manager*{.final.} = object + net*: NET host*: cstring user*: cstring passwd*: cstring @@ -717,24 +734,24 @@ type net_buf_size*: cint last_error*: array[0..(MAX_MYSQL_MANAGER_ERR) - 1, char] - TMANAGER* = Tst_mysql_manager - PMANAGER* = ptr TMANAGER - Pst_mysql_parameters* = ptr Tst_mysql_parameters - Tst_mysql_parameters*{.final.} = object + MANAGER* = St_mysql_manager + PMANAGER* = ptr MANAGER + Pst_mysql_parameters* = ptr St_mysql_parameters + St_mysql_parameters*{.final.} = object p_max_allowed_packet*: ptr int p_net_buffer_length*: ptr int - TPARAMETERS* = Tst_mysql_parameters - PPARAMETERS* = ptr TPARAMETERS - Tenum_mysql_stmt_state* = enum + PARAMETERS* = St_mysql_parameters + PPARAMETERS* = ptr PARAMETERS + Enum_mysql_stmt_state* = enum STMT_INIT_DONE = 1, STMT_PREPARE_DONE, STMT_EXECUTE_DONE, STMT_FETCH_DONE - Pst_mysql_bind* = ptr Tst_mysql_bind - Tst_mysql_bind*{.final.} = object + Pst_mysql_bind* = ptr St_mysql_bind + St_mysql_bind*{.final.} = object len*: int # output length pointer is_null*: Pmy_bool # Pointer to null indicator buffer*: pointer # buffer to get/put data error*: PMy_bool # set this if you want to track data truncations happened during fetch - buffer_type*: Tenum_field_types # buffer type + buffer_type*: Enum_field_types # buffer type buffer_length*: int # buffer length, must be set for str/binary # Following are for internal use. Set by mysql_stmt_bind_param row_ptr*: ptr byte # for the current data position @@ -750,15 +767,15 @@ type fetch_result*: proc (para1: Pst_mysql_bind, para2: PFIELD, row: PPbyte) skip_result*: proc (para1: Pst_mysql_bind, para2: PFIELD, row: PPbyte) - TBIND* = Tst_mysql_bind - PBIND* = ptr TBIND # statement handler - Tst_mysql_stmt*{.final.} = object - mem_root*: TMEM_ROOT # root allocations + BIND* = St_mysql_bind + PBIND* = ptr BIND # statement handler + St_mysql_stmt*{.final.} = object + mem_root*: MEM_ROOT # root allocations mysql*: PMySQL # connection handle params*: PBIND # input parameters `bind`*: PBIND # input parameters fields*: PFIELD # result set metadata - result*: TDATA # cached result set + result*: DATA # cached result set data_cursor*: PROWS # current row in cached result affected_rows*: my_ulonglong # copy of mysql->affected_rows after statement execution insert_id*: my_ulonglong @@ -771,7 +788,7 @@ type last_errno*: cuint # error code param_count*: cuint # input parameter count field_count*: cuint # number of columns in result set - state*: Tenum_mysql_stmt_state # statement state + state*: Enum_mysql_stmt_state # statement state last_error*: array[0..(ERRMSG_SIZE) - 1, char] # error message sqlstate*: array[0..(SQLSTATE_LENGTH + 1) - 1, char] send_types_to_server*: my_bool # Types of input parameters should be sent to server @@ -780,10 +797,23 @@ type unbuffered_fetch_cancelled*: my_bool update_max_length*: my_bool - TSTMT* = Tst_mysql_stmt + STMT* = St_mysql_stmt - Tenum_stmt_attr_type* = enum + Enum_stmt_attr_type* = enum STMT_ATTR_UPDATE_MAX_LENGTH, STMT_ATTR_CURSOR_TYPE, STMT_ATTR_PREFETCH_ROWS +{.deprecated: [Tst_dynamic_array: St_dynamic_array, Tst_mysql_options: St_mysql_options, + TDYNAMIC_ARRAY: DYNAMIC_ARRAY, Tprotocol_type: Protocol_type, + Trpl_type: Rpl_type, Tcharset_info_st: Charset_info_st, + TCHARSET_INFO: CHARSET_INFO, Tcharacter_set: Character_set, + TMY_CHARSET_INFO: MY_CHARSET_INFO, Tst_mysql: St_mysql, + Tst_mysql_methods: St_mysql_methods, TMySql: MySql, + Tst_mysql_res: St_mysql_res, TMETHODS: METHODS, TRES: RES, + Tst_mysql_manager: St_mysql_manager, TMANAGER: MANAGER, + Tst_mysql_parameters: St_mysql_parameters, TPARAMETERS: PARAMETERS, + Tenum_mysql_stmt_state: Enum_mysql_stmt_state, + Tst_mysql_bind: St_mysql_bind, TBIND: BIND, Tst_mysql_stmt: St_mysql_stmt, + TSTMT: STMT, Tenum_stmt_attr_type: Enum_stmt_attr_type, + Tstatus: Status].} proc server_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{. cdecl, dynlib: lib, importc: "mysql_server_init".} @@ -817,9 +847,9 @@ proc fetch_field_direct*(res: PRES, fieldnr: cuint): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_field_direct".} proc fetch_fields*(res: PRES): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_fields".} -proc row_tell*(res: PRES): TROW_OFFSET{.stdcall, dynlib: lib, +proc row_tell*(res: PRES): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_tell".} -proc field_tell*(res: PRES): TFIELD_OFFSET{.stdcall, dynlib: lib, +proc field_tell*(res: PRES): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_tell".} proc field_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_field_count".} @@ -895,7 +925,7 @@ proc disable_reads_from_master*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: " # get the value of the master read flag proc reads_from_master_enabled*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_reads_from_master_enabled".} -proc rpl_query_type*(q: cstring, length: cint): Trpl_type{.stdcall, dynlib: lib, +proc rpl_query_type*(q: cstring, length: cint): Rpl_type{.stdcall, dynlib: lib, importc: "mysql_rpl_query_type".} # discover the master and its slaves proc rpl_probe*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_rpl_probe".} @@ -904,14 +934,14 @@ proc set_master*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passw stdcall, dynlib: lib, importc: "mysql_set_master".} proc add_slave*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passwd: cstring): cint{. stdcall, dynlib: lib, importc: "mysql_add_slave".} -proc shutdown*(MySQL: PMySQL, shutdown_level: Tenum_shutdown_level): cint{.stdcall, +proc shutdown*(MySQL: PMySQL, shutdown_level: Enum_shutdown_level): cint{.stdcall, dynlib: lib, importc: "mysql_shutdown".} proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_dump_debug_info".} proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib, importc: "mysql_refresh".} proc kill*(MySQL: PMySQL, pid: int): cint{.stdcall, dynlib: lib, importc: "mysql_kill".} -proc set_server_option*(MySQL: PMySQL, option: Tenum_mysql_set_option): cint{.stdcall, +proc set_server_option*(MySQL: PMySQL, option: Enum_mysql_set_option): cint{.stdcall, dynlib: lib, importc: "mysql_set_server_option".} proc ping*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_ping".} proc stat*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_stat".} @@ -933,17 +963,17 @@ proc list_tables*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, importc: "mysql_list_tables".} proc list_processes*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, importc: "mysql_list_processes".} -proc options*(MySQL: PMySQL, option: Toption, arg: cstring): cint{.stdcall, dynlib: lib, +proc options*(MySQL: PMySQL, option: Option, arg: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_options".} proc free_result*(result: PRES){.stdcall, dynlib: lib, importc: "mysql_free_result".} proc data_seek*(result: PRES, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_data_seek".} -proc row_seek*(result: PRES, offset: TROW_OFFSET): TROW_OFFSET{.stdcall, +proc row_seek*(result: PRES, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_seek".} -proc field_seek*(result: PRES, offset: TFIELD_OFFSET): TFIELD_OFFSET{.stdcall, +proc field_seek*(result: PRES, offset: FIELD_OFFSET): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_seek".} -proc fetch_row*(result: PRES): TROW{.stdcall, dynlib: lib, +proc fetch_row*(result: PRES): ROW{.stdcall, dynlib: lib, importc: "mysql_fetch_row".} proc fetch_lengths*(result: PRES): ptr int{.stdcall, dynlib: lib, importc: "mysql_fetch_lengths".} @@ -990,9 +1020,9 @@ proc stmt_store_result*(stmt: PSTMT): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_store_result".} proc stmt_param_count*(stmt: PSTMT): int{.stdcall, dynlib: lib, importc: "mysql_stmt_param_count".} -proc stmt_attr_set*(stmt: PSTMT, attr_type: Tenum_stmt_attr_type, attr: pointer): my_bool{. +proc stmt_attr_set*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_set".} -proc stmt_attr_get*(stmt: PSTMT, attr_type: Tenum_stmt_attr_type, attr: pointer): my_bool{. +proc stmt_attr_get*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_get".} proc stmt_bind_param*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_bind_param".} @@ -1017,9 +1047,9 @@ proc stmt_error*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_error".} proc stmt_sqlstate*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_sqlstate".} -proc stmt_row_seek*(stmt: PSTMT, offset: TROW_OFFSET): TROW_OFFSET{.stdcall, +proc stmt_row_seek*(stmt: PSTMT, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_seek".} -proc stmt_row_tell*(stmt: PSTMT): TROW_OFFSET{.stdcall, dynlib: lib, +proc stmt_row_tell*(stmt: PSTMT): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_tell".} proc stmt_data_seek*(stmt: PSTMT, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_stmt_data_seek".} @@ -1066,7 +1096,7 @@ proc IS_BLOB(n: int32): bool = proc IS_NUM_FIELD(f: Pst_mysql_field): bool = result = (f.flags and NUM_FLAG) != 0 -proc IS_NUM(t: Tenum_field_types): bool = +proc IS_NUM(t: Enum_field_types): bool = result = (t <= FIELD_TYPE_INT24) or (t == FIELD_TYPE_YEAR) or (t == FIELD_TYPE_NEWDECIMAL) diff --git a/lib/wrappers/odbcsql.nim b/lib/wrappers/odbcsql.nim index 77719e85f..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,33 +35,44 @@ else: # ftMemo SQL_BINARY // SQL_VARCHAR # -type +type TSqlChar* = char TSqlSmallInt* = int16 - TSqlUSmallInt* = int16 - TSqlHandle* = pointer - TSqlHEnv* = TSqlHandle - TSqlHDBC* = TSqlHandle - TSqlHStmt* = TSqlHandle - TSqlHDesc* = TSqlHandle + SqlUSmallInt* = int16 + SqlHandle* = pointer + SqlHEnv* = SqlHandle + SqlHDBC* = SqlHandle + SqlHStmt* = SqlHandle + SqlHDesc* = SqlHandle TSqlInteger* = int - TSqlUInteger* = int - TSqlPointer* = pointer + SqlUInteger* = int + SqlPointer* = pointer TSqlReal* = cfloat TSqlDouble* = cdouble TSqlFloat* = cdouble - TSqlHWND* = pointer + SqlHWND* = pointer PSQLCHAR* = cstring PSQLINTEGER* = ptr TSqlInteger - PSQLUINTEGER* = ptr TSqlUInteger + PSQLUINTEGER* = ptr SqlUInteger PSQLSMALLINT* = ptr TSqlSmallInt - PSQLUSMALLINT* = ptr TSqlUSmallInt + PSQLUSMALLINT* = ptr SqlUSmallInt PSQLREAL* = ptr TSqlReal PSQLDOUBLE* = ptr TSqlDouble PSQLFLOAT* = ptr TSqlFloat - PSQLHANDLE* = ptr TSqlHandle + PSQLHANDLE* = ptr SqlHandle +{.deprecated: [ + # TSqlChar: TSqlChar, # Name conflict if we drop`T` + # TSqlSmallInt: TSqlSmallInt, # Name conflict if we drop`T` + TSqlUSmallInt: SqlUSmallInt, TSqlHandle: SqlHandle, TSqlHEnv: SqlHEnv, + TSqlHDBC: SqlHDBC, TSqlHStmt: SqlHStmt, TSqlHDesc: SqlHDesc, + # TSqlInteger: TSqlInteger, # Name conflict if we drop `T` + TSqlUInteger: SqlUInteger, TSqlPointer: SqlPointer, + # TSqlReal: TSqlReal, # Name conflict if we drop`T` + # TSqlDouble: TSqlDouble, # Name conflict if we drop`T` + # 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) @@ -84,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 @@ -112,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 @@ -129,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 @@ -186,68 +205,68 @@ 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*: TSqlUSmallInt - Day*: TSqlUSmallInt + Month*: SqlUSmallInt + Day*: SqlUSmallInt PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT - SQL_TIME_STRUCT* {.final, pure.} = object - Hour*: TSqlUSmallInt - Minute*: TSqlUSmallInt - Second*: TSqlUSmallInt + 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 - Year*: TSqlUSmallInt - Month*: TSqlUSmallInt - Day*: TSqlUSmallInt - Hour*: TSqlUSmallInt - Minute*: TSqlUSmallInt - Second*: TSqlUSmallInt - Fraction*: TSqlUInteger + SQL_TIMESTAMP_STRUCT* {.final, pure.} = object + Year*: SqlUSmallInt + Month*: SqlUSmallInt + Day*: SqlUSmallInt + Hour*: SqlUSmallInt + Minute*: SqlUSmallInt + Second*: SqlUSmallInt + Fraction*: SqlUInteger 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 @@ -264,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 @@ -297,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 @@ -325,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 @@ -338,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 @@ -347,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 @@ -423,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 @@ -451,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 @@ -463,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 @@ -479,46 +498,46 @@ 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_NULL_HENV* = TSqlHEnv(nil) - SQL_NULL_HDBC* = TSqlHDBC(nil) - SQL_NULL_HSTMT* = TSqlHStmt(nil) - SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */ - SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */ + SQL_FETCH_RELATIVE* = 6 + SQL_NULL_HENV* = SqlHEnv(nil) + SQL_NULL_HDBC* = SqlHDBC(nil) + SQL_NULL_HSTMT* = SqlHStmt(nil) + SQL_NULL_HDESC* = SqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */ + SQL_NULL_HANDLE* = SqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */ SQL_SCOPE_CURROW* = 0 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() */ @@ -527,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 @@ -559,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 @@ -622,167 +641,167 @@ const ODBC_CONFIG_SYS_DSN* = 5 ODBC_REMOVE_SYS_DSN* = 6 -proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle, - OutputHandlePtr: var TSqlHandle): TSqlSmallInt{. +proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle, + OutputHandlePtr: var SqlHandle): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, - Value: TSqlPointer, 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: TSqlHandle): TSqlSmallInt{. +proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: SqlHandle): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle, - 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: TSqlHandle, - RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, - DiagInfoPtr: TSqlPointer, 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: TSqlHDBC, 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: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib, +proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring, - szCLen: TSqlSmallInt, szCsout: cstring, - cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, - f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR, - cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, - cbConnStrOutMax: 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, cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, +proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, +proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, +proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{. +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: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, - NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, - ColumnSize: var TSqlUInteger, +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: TSqlHStmt, FetchOrientation: TSqlSmallInt, - FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, +proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt, + FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt, - 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: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - TargetType: TSqlSmallInt, TargetValue: TSqlPointer, +proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: SqlPointer, BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, - Value: TSqlPointer, 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: TSqlHDBC, InfoType: TSqlUSmallInt, - InfoValue: TSqlPointer, 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: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{. +proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer, +proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer, StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - TargetType: TSqlSmallInt, TargetValue: TSqlPointer, +proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: SqlPointer, BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt, - fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, - ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, - NameLength1: PSQLSMALLINT, Description: PSQLCHAR, +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, BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, - 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: TSqlHDBC, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, +proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, - NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, +proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, + NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{. +proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt, - fParamType: TSqlSmallInt, fCType: TSqlSmallInt, - fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger, - ibScale: TSqlSmallInt, rgbValue: TSqlPointer, +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: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{. +proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - FieldIdentifier: TSqlUSmallInt, - CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, - StringLength: PSQLSMALLINT, - NumericAttribute: TSqlPointer): TSqlSmallInt{. +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: TSqlHandle, - CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, +proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle, + CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLTables*(hstmt: TSqlHStmt, 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: TSqlHStmt, 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: TSqlHStmt, IdentifierType: TSqlUSmallInt, - CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, - SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, - TableName: PSQLCHAR, NameLength3: TSqlSmallInt, - Scope: TSqlUSmallInt, - Nullable: TSqlUSmallInt): TSqlSmallInt{. +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: TSqlHStmt, 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: TSqlHStmt, 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: TSqlHStmt, 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: TSqlHStmt, CatalogName: PSQLCHAR, - NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, - NameLength2: TSqlSmallInt, TableName: PSQLCHAR, - NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt, - Reserved: TSqlUSmallInt): TSqlSmallInt {. +proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, + NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, + NameLength2: TSqlSmallInt, TableName: PSQLCHAR, + NameLength3: TSqlSmallInt, Unique: SqlUSmallInt, + Reserved: SqlUSmallInt): TSqlSmallInt {. dynlib: odbclib, importc.} {.pop.} 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 afa8f447a..4b6acce01 100644 --- a/lib/wrappers/pcre.nim +++ b/lib/wrappers/pcre.nim @@ -1,158 +1,163 @@ -#************************************************ -# 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-2010 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.} -when not defined(pcreDll): - when hostOS == "windows": - const pcreDll = "pcre.dll" - elif hostOS == "macosx": - const pcreDll = "libpcre(.3|.1|).dylib" - else: - const pcreDll = "libpcre.so(.3|.1|)" - {.pragma: pcreImport, dynlib: pcreDll.} -else: - {.pragma: pcreImport, header: "<pcre.h>".} +{.deadCodeElim: on.} -# The current PCRE version information. +# The current PCRE version information. -const - MAJOR* = 8 - MINOR* = 31 - PRERELEASE* = true - DATE* = "2012-07-06" +const + PCRE_MAJOR* = 8 + PCRE_MINOR* = 36 + PCRE_PRERELEASE* = true + PCRE_DATE* = "2014-09-26" # When an application links to a PCRE DLL in Windows, the symbols that are # imported have to be identified as such. When building PCRE, the appropriate # export setting is defined in pcre_internal.h, which includes this file. So we -# don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. - -# Have to include stdlib.h in order to ensure that size_t is defined; -# it is needed here for malloc. - -# Allow for C++ users - -# Options. Some are compile-time only, some are run-time only, and some are -# both, so we keep them all distinct. - -const - CASELESS* = 0x00000001 - MULTILINE* = 0x00000002 - DOTALL* = 0x00000004 - EXTENDED* = 0x00000008 - ANCHORED* = 0x00000010 - DOLLAR_ENDONLY* = 0x00000020 - EXTRA* = 0x00000040 - NOTBOL* = 0x00000080 - NOTEOL* = 0x00000100 - UNGREEDY* = 0x00000200 - NOTEMPTY* = 0x00000400 - UTF8* = 0x00000800 - NO_AUTO_CAPTURE* = 0x00001000 - NO_UTF8_CHECK* = 0x00002000 - AUTO_CALLOUT* = 0x00004000 - PARTIAL_SOFT* = 0x00008000 - PARTIAL* = 0x00008000 # Backwards compatible synonym - DFA_SHORTEST* = 0x00010000 - DFA_RESTART* = 0x00020000 - FIRSTLINE* = 0x00040000 - DUPNAMES* = 0x00080000 - NEWLINE_CR* = 0x00100000 - NEWLINE_LF* = 0x00200000 - NEWLINE_CRLF* = 0x00300000 - NEWLINE_ANY* = 0x00400000 - NEWLINE_ANYCRLF* = 0x00500000 - BSR_ANYCRLF* = 0x00800000 - BSR_UNICODE* = 0x01000000 - JAVASCRIPT_COMPAT* = 0x02000000 - NO_START_OPTIMIZE* = 0x04000000 - NO_START_OPTIMISE* = 0x04000000 - PARTIAL_HARD* = 0x08000000 - NOTEMPTY_ATSTART* = 0x10000000 - UCP* = 0x20000000 - -# Exec-time and get/set-time error codes - -const - ERROR_NOMATCH* = (- 1) - ERROR_NULL* = (- 2) - ERROR_BADOPTION* = (- 3) - ERROR_BADMAGIC* = (- 4) - ERROR_UNKNOWN_OPCODE* = (- 5) - ERROR_UNKNOWN_NODE* = (- 5) # For backward compatibility - ERROR_NOMEMORY* = (- 6) - ERROR_NOSUBSTRING* = (- 7) - ERROR_MATCHLIMIT* = (- 8) - ERROR_CALLOUT* = (- 9) # Never used by PCRE itself - ERROR_BADUTF8* = (- 10) - ERROR_BADUTF8_OFFSET* = (- 11) - ERROR_PARTIAL* = (- 12) - ERROR_BADPARTIAL* = (- 13) - ERROR_INTERNAL* = (- 14) - ERROR_BADCOUNT* = (- 15) - ERROR_DFA_UITEM* = (- 16) - ERROR_DFA_UCOND* = (- 17) - ERROR_DFA_UMLIMIT* = (- 18) - ERROR_DFA_WSSIZE* = (- 19) - ERROR_DFA_RECURSE* = (- 20) - ERROR_RECURSIONLIMIT* = (- 21) - ERROR_NULLWSLIMIT* = (- 22) # No longer actually used - ERROR_BADNEWLINE* = (- 23) - ERROR_BADOFFSET* = (- 24) - ERROR_SHORTUTF8* = (- 25) - ERROR_RECURSELOOP* = (- 26) - ERROR_JIT_STACKLIMIT* = (- 27) - ERROR_BADMODE* = (- 28) - ERROR_BADENDIANNESS* = (- 29) - ERROR_DFA_BADRESTART* = (- 30) - -# Specific error codes for UTF-8 validity checks +# don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. + +# By default, we use the standard "extern" declarations. + +# Allow for C++ users +# Public options. Some are compile-time only, some are run-time only, and some +# are both. Most of the compile-time options are saved with the compiled regex +# so that they can be inspected during studying (and therefore JIT compiling). +# Note that pcre_study() has its own set of options. Originally, all the options +# defined here used distinct bits. However, almost all the bits in a 32-bit word +# are now used, so in order to conserve them, option bits that were previously +# only recognized at matching time (i.e. by pcre_exec() or pcre_dfa_exec()) may +# also be used for compile-time options that affect only compiling and are not +# relevant for studying or JIT compiling. +# +# Some options for pcre_compile() change its behaviour but do not affect the +# behaviour of the execution functions. Other options are passed through to the +# execution functions and affect their behaviour, with or without affecting the +# behaviour of pcre_compile(). +# +# Options that can be passed to pcre_compile() are tagged Cx below, with these +# variants: +# +# C1 Affects compile only +# C2 Does not affect compile; affects exec, dfa_exec +# C3 Affects compile, exec, dfa_exec +# 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 +# flagged with J. + +const + CASELESS* = 0x00000001 # C1 + MULTILINE* = 0x00000002 # C1 + DOTALL* = 0x00000004 # C1 + EXTENDED* = 0x00000008 # C1 + ANCHORED* = 0x00000010 # C4 E D + DOLLAR_ENDONLY* = 0x00000020 # C2 + EXTRA* = 0x00000040 # C1 + NOTBOL* = 0x00000080 # E D J + NOTEOL* = 0x00000100 # E D J + UNGREEDY* = 0x00000200 # C1 + NOTEMPTY* = 0x00000400 # E D J + UTF8* = 0x00000800 # C4 ) + UTF16* = 0x00000800 # C4 ) Synonyms + UTF32* = 0x00000800 # C4 ) + NO_AUTO_CAPTURE* = 0x00001000 # C1 + NO_UTF8_CHECK* = 0x00002000 # C1 E D J ) + NO_UTF16_CHECK* = 0x00002000 # C1 E D J ) Synonyms + NO_UTF32_CHECK* = 0x00002000 # C1 E D J ) + AUTO_CALLOUT* = 0x00004000 # C1 + PARTIAL_SOFT* = 0x00008000 # E D J ) Synonyms + PARTIAL* = 0x00008000 # E D J ) + +# This pair use the same bit. +const + NEVER_UTF* = 0x00010000 # C1 ) Overlaid + DFA_SHORTEST* = 0x00010000 # D ) Overlaid + +# This pair use the same bit. +const + NO_AUTO_POSSESS* = 0x00020000 # C1 ) Overlaid + DFA_RESTART* = 0x00020000 # D ) Overlaid + +const + FIRSTLINE* = 0x00040000 # C3 + DUPNAMES* = 0x00080000 # C1 + NEWLINE_CR* = 0x00100000 # C3 E D + NEWLINE_LF* = 0x00200000 # C3 E D + NEWLINE_CRLF* = 0x00300000 # C3 E D + NEWLINE_ANY* = 0x00400000 # C3 E D + NEWLINE_ANYCRLF* = 0x00500000 # C3 E D + BSR_ANYCRLF* = 0x00800000 # C3 E D + BSR_UNICODE* = 0x01000000 # C3 E D + JAVASCRIPT_COMPAT* = 0x02000000 # C5 + NO_START_OPTIMIZE* = 0x04000000 # C2 E D ) Synonyms + NO_START_OPTIMISE* = 0x04000000 # C2 E D ) + PARTIAL_HARD* = 0x08000000 # E D J + NOTEMPTY_ATSTART* = 0x10000000 # E D J + UCP* = 0x20000000 # C3 + +## Exec-time and get/set-time error codes const - UTF8_ERR0* = 0 - UTF8_ERR1* = 1 - UTF8_ERR2* = 2 - UTF8_ERR3* = 3 - UTF8_ERR4* = 4 - UTF8_ERR5* = 5 - UTF8_ERR6* = 6 - UTF8_ERR7* = 7 - UTF8_ERR8* = 8 - UTF8_ERR9* = 9 + ERROR_NOMATCH* = -1 + ERROR_NULL* = -2 + ERROR_BADOPTION* = -3 + ERROR_BADMAGIC* = -4 + ERROR_UNKNOWN_OPCODE* = -5 + ERROR_UNKNOWN_NODE* = -5 ## For backward compatibility + ERROR_NOMEMORY* = -6 + ERROR_NOSUBSTRING* = -7 + ERROR_MATCHLIMIT* = -8 + ERROR_CALLOUT* = -9 ## Never used by PCRE itself + ERROR_BADUTF8* = -10 ## Same for 8/16/32 + ERROR_BADUTF16* = -10 ## Same for 8/16/32 + ERROR_BADUTF32* = -10 ## Same for 8/16/32 + ERROR_BADUTF8_OFFSET* = -11 ## Same for 8/16 + ERROR_BADUTF16_OFFSET* = -11 ## Same for 8/16 + ERROR_PARTIAL* = -12 + ERROR_BADPARTIAL* = -13 + ERROR_INTERNAL* = -14 + ERROR_BADCOUNT* = -15 + ERROR_DFA_UITEM* = -16 + ERROR_DFA_UCOND* = -17 + ERROR_DFA_UMLIMIT* = -18 + ERROR_DFA_WSSIZE* = -19 + ERROR_DFA_RECURSE* = -20 + ERROR_RECURSIONLIMIT* = -21 + ERROR_NULLWSLIMIT* = -22 ## No longer actually used + ERROR_BADNEWLINE* = -23 + ERROR_BADOFFSET* = -24 + ERROR_SHORTUTF8* = -25 + ERROR_SHORTUTF16* = -25 ## Same for 8/16 + ERROR_RECURSELOOP* = -26 + ERROR_JIT_STACKLIMIT* = -27 + ERROR_BADMODE* = -28 + ERROR_BADENDIANNESS* = -29 + ERROR_DFA_BADRESTART* = -30 + ERROR_JIT_BADOPTION* = -31 + ERROR_BADLENGTH* = -32 + ERROR_UNSET* = -33 + +## Specific error codes for UTF-8 validity checks +const + UTF8_ERR0* = 0 + UTF8_ERR1* = 1 + UTF8_ERR2* = 2 + UTF8_ERR3* = 3 + UTF8_ERR4* = 4 + UTF8_ERR5* = 5 + UTF8_ERR6* = 6 + UTF8_ERR7* = 7 + UTF8_ERR8* = 8 + UTF8_ERR9* = 9 UTF8_ERR10* = 10 UTF8_ERR11* = 11 UTF8_ERR12* = 12 @@ -165,193 +170,305 @@ const UTF8_ERR19* = 19 UTF8_ERR20* = 20 UTF8_ERR21* = 21 + UTF8_ERR22* = 22 # Unused (was non-character) + +## Specific error codes for UTF-16 validity checks +const + UTF16_ERR0* = 0 + UTF16_ERR1* = 1 + UTF16_ERR2* = 2 + UTF16_ERR3* = 3 + UTF16_ERR4* = 4 # Unused (was non-character) -# Request types for pcre_fullinfo() - -const - INFO_OPTIONS* = 0 - INFO_SIZE* = 1 - INFO_CAPTURECOUNT* = 2 - INFO_BACKREFMAX* = 3 - INFO_FIRSTBYTE* = 4 - INFO_FIRSTCHAR* = 4 # For backwards compatibility - INFO_FIRSTTABLE* = 5 - INFO_LASTLITERAL* = 6 - INFO_NAMEENTRYSIZE* = 7 - INFO_NAMECOUNT* = 8 - INFO_NAMETABLE* = 9 - INFO_STUDYSIZE* = 10 - INFO_DEFAULT_TABLES* = 11 - INFO_OKPARTIAL* = 12 - INFO_JCHANGED* = 13 - INFO_HASCRORLF* = 14 - INFO_MINLENGTH* = 15 - INFO_JIT* = 16 - INFO_JITSIZE* = 17 - INFO_MAXLOOKBEHIND* = 18 - -# Request types for pcre_config(). Do not re-arrange, in order to remain -# compatible. - -const - CONFIG_UTF8* = 0 - CONFIG_NEWLINE* = 1 - CONFIG_LINK_SIZE* = 2 - CONFIG_POSIX_MALLOC_THRESHOLD* = 3 - CONFIG_MATCH_LIMIT* = 4 - CONFIG_STACKRECURSE* = 5 - CONFIG_UNICODE_PROPERTIES* = 6 - CONFIG_MATCH_LIMIT_RECURSION* = 7 - CONFIG_BSR* = 8 - CONFIG_JIT* = 9 - CONFIG_JITTARGET* = 11 - -# Request types for pcre_study(). Do not re-arrange, in order to remain -# compatible. +## Specific error codes for UTF-32 validity checks +const + UTF32_ERR0* = 0 + UTF32_ERR1* = 1 + UTF32_ERR2* = 2 # Unused (was non-character) + UTF32_ERR3* = 3 +## Request types for pcre_fullinfo() +const + INFO_OPTIONS* = 0 + INFO_SIZE* = 1 + INFO_CAPTURECOUNT* = 2 + INFO_BACKREFMAX* = 3 + INFO_FIRSTBYTE* = 4 + INFO_FIRSTCHAR* = 4 ## For backwards compatibility + INFO_FIRSTTABLE* = 5 + INFO_LASTLITERAL* = 6 + INFO_NAMEENTRYSIZE* = 7 + INFO_NAMECOUNT* = 8 + INFO_NAMETABLE* = 9 + INFO_STUDYSIZE* = 10 + INFO_DEFAULT_TABLES* = 11 + INFO_OKPARTIAL* = 12 + INFO_JCHANGED* = 13 + INFO_HASCRORLF* = 14 + INFO_MINLENGTH* = 15 + INFO_JIT* = 16 + INFO_JITSIZE* = 17 + INFO_MAXLOOKBEHIND* = 18 + INFO_FIRSTCHARACTER* = 19 + INFO_FIRSTCHARACTERFLAGS* = 20 + INFO_REQUIREDCHAR* = 21 + INFO_REQUIREDCHARFLAGS* = 22 + INFO_MATCHLIMIT* = 23 + INFO_RECURSIONLIMIT* = 24 + INFO_MATCH_EMPTY* = 25 + +## Request types for pcre_config(). Do not re-arrange, in order to remain +## compatible. const - STUDY_JIT_COMPILE* = 0x00000001 - STUDY_JIT_PARTIAL_SOFT_COMPILE* = 0x00000002 - STUDY_JIT_PARTIAL_HARD_COMPILE* = 0x00000004 - -# Bit flags for the pcre_extra structure. Do not re-arrange or redefine -# these bits, just add new ones on the end, in order to remain compatible. - -const - EXTRA_STUDY_DATA* = 0x00000001 - EXTRA_MATCH_LIMIT* = 0x00000002 - EXTRA_CALLOUT_DATA* = 0x00000004 - EXTRA_TABLES* = 0x00000008 - EXTRA_MATCH_LIMIT_RECURSION* = 0x00000010 - EXTRA_MARK* = 0x00000020 - EXTRA_EXECUTABLE_JIT* = 0x00000040 - -# Types - -type - TPcre*{.pure, final.} = object - PPcre* = ptr TPcre - Tjit_stack*{.pure, final.} = object - Pjit_stack* = ptr Tjit_stack - -# When PCRE is compiled as a C++ library, the subject pointer type can be -# replaced with a custom type. For conventional use, the public interface is a -# const char *. - -# The structure for passing additional data to pcre_exec(). This is defined in -# such as way as to be extensible. Always add new fields at the end, in order to -# remain compatible. - -type - TExtra*{.pure, final.} = object - flags*: int ## Bits for which fields are set - study_data*: pointer ## Opaque data from pcre_study() - match_limit*: int ## Maximum number of calls to match() - callout_data*: pointer ## Data passed back in callouts - tables*: cstring ## Pointer to character tables - match_limit_recursion*: int ## Max recursive calls to match() - mark*: ptr cstring ## For passing back a mark pointer - executable_jit*: pointer ## Contains a pointer to a compiled jit code - - -# The structure for passing out data via the pcre_callout_function. We use a -# structure so that new fields can be added on the end in future versions, -# without changing the API of the function, thereby allowing old clients to work -# without modification. - -type - TCalloutBlock*{.pure, final.} = object - version*: cint ## Identifies version of block - callout_number*: cint ## Number compiled into pattern - offset_vector*: ptr cint ## The offset vector - subject*: cstring ## The subject being matched - subject_length*: cint ## The length of the subject - start_match*: cint ## Offset to start of this match attempt - current_position*: cint ## Where we currently are in the subject - capture_top*: cint ## Max current capture - capture_last*: cint ## Most recently closed capture - callout_data*: pointer ## Data passed in with the call - pattern_position*: cint ## Offset to next item in the pattern - next_item_length*: cint ## Length of next item in the pattern - mark*: cstring ## Pointer to current mark or NULL - -# Indirection for store get and free functions. These can be set to -#alternative malloc/free functions if required. Special ones are used in the -#non-recursive case for "frames". There is also an optional callout function -#that is triggered by the (?) regex item. For Virtual Pascal, these definitions -#have to take another form. - -# User defined callback which provides a stack just before the match starts. + CONFIG_UTF8* = 0 + CONFIG_NEWLINE* = 1 + CONFIG_LINK_SIZE* = 2 + CONFIG_POSIX_MALLOC_THRESHOLD* = 3 + CONFIG_MATCH_LIMIT* = 4 + CONFIG_STACKRECURSE* = 5 + CONFIG_UNICODE_PROPERTIES* = 6 + CONFIG_MATCH_LIMIT_RECURSION* = 7 + CONFIG_BSR* = 8 + CONFIG_JIT* = 9 + CONFIG_UTF16* = 10 + CONFIG_JITTARGET* = 11 + CONFIG_UTF32* = 12 + CONFIG_PARENS_LIMIT* = 13 + +## Request types for pcre_study(). Do not re-arrange, in order to remain +## compatible. +const + STUDY_JIT_COMPILE* = 0x0001 + STUDY_JIT_PARTIAL_SOFT_COMPILE* = 0x0002 + STUDY_JIT_PARTIAL_HARD_COMPILE* = 0x0004 + STUDY_EXTRA_NEEDED* = 0x0008 + +## Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine +## these bits, just add new ones on the end, in order to remain compatible. +const + EXTRA_STUDY_DATA* = 0x0001 + EXTRA_MATCH_LIMIT* = 0x0002 + EXTRA_CALLOUT_DATA* = 0x0004 + EXTRA_TABLES* = 0x0008 + EXTRA_MATCH_LIMIT_RECURSION* = 0x0010 + EXTRA_MARK* = 0x0020 + EXTRA_EXECUTABLE_JIT* = 0x0040 + +## Types +type + Pcre* = object + Pcre16* = object + Pcre32* = object + JitStack* = object + JitStack16* = object + JitStack32* = object + +## The structure for passing additional data to pcre_exec(). This is defined in +## such as way as to be extensible. Always add new fields at the end, in order +## to remain compatible. type - TJitCallback* = proc(p: pointer): ptr Tjit_stack{.cdecl.} - -# Exported PCRE functions - -proc compile*(a2: cstring, a3: cint, a4: ptr cstring, a5: ptr cint, - a6: ptr char): ptr TPcre{.cdecl, importc: "pcre_compile", - pcreImport.} -proc compile2*(a2: cstring, a3: cint, a4: ptr cint, a5: ptr cstring, - a6: ptr cint, a7: ptr char): ptr TPcre{.cdecl, - importc: "pcre_compile2", pcreImport.} -proc config*(a2: cint, a3: pointer): cint{.cdecl, importc: "pcre_config", - pcreImport.} -proc copy_named_substring*(a2: ptr TPcre, a3: cstring, a4: ptr cint, a5: cint, - a6: cstring, a7: cstring, a8: cint): cint{.cdecl, - importc: "pcre_copy_named_substring", pcreImport.} -proc copy_substring*(a2: cstring, a3: ptr cint, a4: cint, a5: cint, - a6: cstring, - a7: cint): cint{.cdecl, importc: "pcre_copy_substring", - pcreImport.} -proc dfa_exec*(a2: ptr TPcre, a3: ptr TExtra, a4: cstring, a5: cint, - a6: cint, a7: cint, a8: ptr cint, a9: cint, a10: ptr cint, - a11: cint): cint{.cdecl, importc: "pcre_dfa_exec", - pcreImport.} -proc exec*(a2: ptr TPcre, a3: ptr TExtra, a4: cstring, a5: cint, a6: cint, - a7: cint, a8: ptr cint, a9: cint): cint {. - cdecl, importc: "pcre_exec", pcreImport.} -proc free_substring*(a2: cstring){.cdecl, importc: "pcre_free_substring", - pcreImport.} -proc free_substring_list*(a2: cstringArray){.cdecl, - importc: "pcre_free_substring_list", pcreImport.} -proc fullinfo*(a2: ptr TPcre, a3: ptr TExtra, a4: cint, a5: pointer): cint{. - cdecl, importc: "pcre_fullinfo", pcreImport.} -proc get_named_substring*(a2: ptr TPcre, a3: cstring, a4: ptr cint, a5: cint, - a6: cstring, a7: cstringArray): cint{.cdecl, - importc: "pcre_get_named_substring", pcreImport.} -proc get_stringnumber*(a2: ptr TPcre, a3: cstring): cint{.cdecl, - importc: "pcre_get_stringnumber", pcreImport.} -proc get_stringtable_entries*(a2: ptr TPcre, a3: cstring, a4: cstringArray, - a5: cstringArray): cint{.cdecl, - importc: "pcre_get_stringtable_entries", pcreImport.} -proc get_substring*(a2: cstring, a3: ptr cint, a4: cint, a5: cint, - a6: cstringArray): cint{.cdecl, - importc: "pcre_get_substring", pcreImport.} -proc get_substring_list*(a2: cstring, a3: ptr cint, a4: cint, - a5: ptr cstringArray): cint{.cdecl, - importc: "pcre_get_substring_list", pcreImport.} -proc maketables*(): ptr char{.cdecl, importc: "pcre_maketables", - pcreImport.} -proc refcount*(a2: ptr TPcre, a3: cint): cint{.cdecl, importc: "pcre_refcount", - pcreImport.} -proc study*(a2: ptr TPcre, a3: cint, a4: var cstring): ptr TExtra{.cdecl, - importc: "pcre_study", pcreImport.} -proc version*(): cstring{.cdecl, importc: "pcre_version", pcreImport.} + ExtraData* = object + flags*: clong ## Bits for which fields are set + study_data*: pointer ## Opaque data from pcre_study() + match_limit*: clong ## Maximum number of calls to match() + callout_data*: pointer ## Data passed back in callouts + tables*: pointer ## Pointer to character tables + match_limit_recursion*: clong ## Max recursive calls to match() + mark*: pointer ## For passing back a mark pointer + executable_jit*: pointer ## Contains a pointer to a compiled jit code + +## The structure for passing out data via the pcre_callout_function. We use a +## structure so that new fields can be added on the end in future versions, +## without changing the API of the function, thereby allowing old clients to +## work without modification. +type + CalloutBlock* = object + version* : cint ## Identifies version of block + # ------------------------ Version 0 ------------------------------- + callout_number* : cint ## Number compiled into pattern + offset_vector* : ptr cint ## The offset vector + subject* : cstring ## The subject being matched + subject_length* : cint ## The length of the subject + start_match* : cint ## Offset to start of this match attempt + current_position*: cint ## Where we currently are in the subject + capture_top* : cint ## Max current capture + capture_last* : cint ## Most recently closed capture + callout_data* : pointer ## Data passed in with the call + # ------------------- Added for Version 1 -------------------------- + pattern_position*: cint ## Offset to next item in the pattern + next_item_length*: cint ## Length of next item in the pattern + # ------------------- Added for Version 2 -------------------------- + mark* : pointer ## Pointer to current mark or NULL + # ------------------------------------------------------------------ + + +## User defined callback which provides a stack just before the match starts. +type + JitCallback* = proc (a: pointer): ptr JitStack {.cdecl.} + + +when not defined(usePcreHeader): + when hostOS == "windows": + const pcreDll = "pcre.dll" + elif hostOS == "macosx": + const pcreDll = "libpcre(.3|.1|).dylib" + else: + const pcreDll = "libpcre.so(.3|.1|)" + {.push dynlib: pcreDll.} +else: + {.push header: "<pcre.h>".} + +{.push cdecl, importc: "pcre_$1".} + +# Exported PCRE functions + +proc compile*(pattern: cstring, + options: cint, + errptr: ptr cstring, + erroffset: ptr cint, + tableptr: pointer): ptr Pcre + +proc compile2*(pattern: cstring, + options: cint, + errorcodeptr: ptr cint, + errptr: ptr cstring, + erroffset: ptr cint, + tableptr: pointer): ptr Pcre + +proc config*(what: cint, + where: pointer): cint + +proc copy_named_substring*(code: ptr Pcre, + subject: cstring, + ovector: ptr cint, + stringcount: cint, + stringname: cstring, + buffer: cstring, + buffersize: cint): cint + +proc copy_substring*(subject: cstring, + ovector: ptr cint, + stringcount: cint, + stringnumber: cint, + buffer: cstring, + buffersize: cint): cint + +proc dfa_exec*(code: ptr Pcre, + extra: ptr ExtraData, + subject: cstring, + length: cint, + startoffset: cint, + options: cint, + ovector: ptr cint, + ovecsize: cint, + workspace: ptr cint, + wscount: cint): cint + +proc exec*(code: ptr Pcre, + extra: ptr ExtraData, + subject: cstring, + length: cint, + startoffset: cint, + options: cint, + ovector: ptr cint, + ovecsize: cint): cint + +proc jit_exec*(code: ptr Pcre, + extra: ptr ExtraData, + subject: cstring, + length: cint, + startoffset: cint, + options: cint, + ovector: ptr cint, + ovecsize: cint, + jstack: ptr JitStack): cint + +proc free_substring*(stringptr: cstring) + +proc free_substring_list*(stringptr: cstringArray) + +proc fullinfo*(code: ptr Pcre, + extra: ptr ExtraData, + what: cint, + where: pointer): cint + +proc get_named_substring*(code: ptr Pcre, + subject: cstring, + ovector: ptr cint, + stringcount: cint, + stringname: cstring, + stringptr: cstringArray): cint + +proc get_stringnumber*(code: ptr Pcre, + name: cstring): cint + +proc get_stringtable_entries*(code: ptr Pcre, + name: cstring, + first: cstringArray, + last: cstringArray): cint + +proc get_substring*(subject: cstring, + ovector: ptr cint, + stringcount: cint, + stringnumber: cint, + stringptr: cstringArray): cint + +proc get_substring_list*(subject: cstring, + ovector: ptr cint, + stringcount: cint, + listptr: ptr cstringArray): cint + +proc maketables*(): pointer + +proc refcount*(code: ptr Pcre, + adjust: cint): cint + +proc study*(code: ptr Pcre, + options: cint, + errptr: ptr cstring): ptr ExtraData + +proc free_study*(extra: ptr ExtraData) + +proc version*(): cstring # Utility functions for byte order swaps. -proc pattern_to_host_byte_order*(a2: ptr TPcre, a3: ptr TExtra, - a4: ptr char): cint{.cdecl, importc: "pcre_pattern_to_host_byte_order", - pcreImport.} +proc pattern_to_host_byte_order*(code: ptr Pcre, + extra: ptr ExtraData, + tables: pointer): cint # JIT compiler related functions. -proc jit_stack_alloc*(a2: cint, a3: cint): ptr Tjit_stack{.cdecl, - importc: "pcre_jit_stack_alloc", pcreImport.} -proc jit_stack_free*(a2: ptr Tjit_stack){.cdecl, importc: "pcre_jit_stack_free", - pcreImport.} -proc assign_jit_stack*(a2: ptr TExtra, a3: TJitCallback, a4: pointer){.cdecl, - importc: "pcre_assign_jit_stack", pcreImport.} +proc jit_stack_alloc*(startsize: cint, + maxsize: cint): ptr JitStack + +proc jit_stack_free*(stack: ptr JitStack) + +proc assign_jit_stack*(extra: ptr ExtraData, + callback: JitCallback, + data: pointer) + +proc jit_free_unused_memory*() + + +# There was an odd function with `var cstring` instead of `ptr` +proc study*(code: ptr Pcre, + options: cint, + errptr: var cstring): ptr ExtraData {.deprecated.} + +{.pop.} +{.pop.} + + +{.deprecated: [MAJOR: PCRE_MAJOR, MINOR: PCRE_MINOR, + PRERELEASE: PCRE_PRERELEASE, DATE: PCRE_DATE].} + +{.deprecated: [TPcre: Pcre, TJitStack: JitStack].} +type + PPcre* {.deprecated.} = ptr Pcre + PJitStack* {.deprecated.} = ptr JitStack -var - pcre_free*: proc (p: ptr TPcre) {.cdecl.} +{.deprecated: [TExtra: ExtraData].} +{.deprecated: [TCalloutBlock: CalloutBlock].} +{.deprecated: [TJitCallback: JitCallback].} diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim index bed69648a..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,103 +403,107 @@ 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 - - TMEVENT*{.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 MOUSE_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() - - TWINDOW*{.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 TWINDOW # subwin's pointer to parent win - - TPANELOBS*{.pure, final.} = object - above*: ptr TPANELOBS - pan*: ptr TPANEL + 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 - TPANEL*{.pure, final.} = object - win*: ptr TWINDOW + PANEL*{.pure, final.} = object + win*: ptr WINDOW wstarty*: cint wendy*: cint wstartx*: cint wendx*: cint - below*: ptr TPANEL - above*: ptr TPANEL + below*: ptr PANEL + above*: ptr PANEL user*: pointer - obscure*: ptr TPANELOBS + obscure*: ptr PANELOBS +{.deprecated: [ + #TMOUSE_STATUS: MOUSE_STATUS, # Name conflict when we drop the `T` + TMEVENT: MEVENT, TWINDOW: WINDOW, + TPANELOBS: PANELOBS, TPANEL:PANEL].} when unixOS: type - TSCREEN*{.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 TWINDOW # 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 @@ -498,70 +511,72 @@ 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 - TSCREEN*{.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 TWINDOW # 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 LINES*{.importc: "LINES", dynlib: pdcursesdll.}: cint COLS*{.importc: "COLS", dynlib: pdcursesdll.}: cint - stdscr*{.importc: "stdscr", dynlib: pdcursesdll.}: ptr TWINDOW - curscr*{.importc: "curscr", dynlib: pdcursesdll.}: ptr TWINDOW - SP*{.importc: "SP", dynlib: pdcursesdll.}: ptr TSCREEN - Mouse_status*{.importc: "Mouse_status", dynlib: pdcursesdll.}: TMOUSE_STATUS + stdscr*{.importc: "stdscr", dynlib: pdcursesdll.}: ptr WINDOW + curscr*{.importc: "curscr", dynlib: pdcursesdll.}: ptr WINDOW + SP*{.importc: "SP", dynlib: pdcursesdll.}: ptr SCREEN + Mouse_status*{.importc: "Mouse_status", dynlib: pdcursesdll.}: MOUSE_STATUS COLORS*{.importc: "COLORS", dynlib: pdcursesdll.}: cint COLOR_PAIRS*{.importc: "COLOR_PAIRS", dynlib: pdcursesdll.}: cint TABSIZE*{.importc: "TABSIZE", dynlib: pdcursesdll.}: cint 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 @@ -659,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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: ptr TWINDOW; 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 TSCREEN){.extdecl, importc: "delscreen", +proc delscreen*(a2: ptr SCREEN){.extdecl, importc: "delscreen", dynlib: pdcursesdll.} -proc delwin*(a2: ptr TWINDOW): cint{.extdecl, importc: "delwin", +proc delwin*(a2: ptr WINDOW): cint{.extdecl, importc: "delwin", dynlib: pdcursesdll.} -proc derwin*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +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 TWINDOW): ptr TWINDOW{.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.} @@ -736,614 +751,614 @@ 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 TWINDOW): 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 TWINDOW{.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 TWINDOW; a3: cunsignedchar){.extdecl, importc: "idcok", +proc idcok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "idcok", dynlib: pdcursesdll.} -proc idlok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok", +proc idlok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok", dynlib: pdcursesdll.} -proc immedok*(a2: ptr TWINDOW; 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 TWINDOW{.extdecl, importc: "initscr", dynlib: pdcursesdll.} -proc innstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innstr", +proc initscr*(): ptr WINDOW{.extdecl, importc: "initscr", dynlib: pdcursesdll.} +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 TWINDOW; 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 TWINDOW; a3: cint): cunsignedchar{.extdecl, +proc is_linetouched*(a2: ptr WINDOW; a3: cint): cunsignedchar{.extdecl, importc: "is_linetouched", dynlib: pdcursesdll.} -proc is_wintouched*(a2: ptr TWINDOW): 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwaddchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwaddchstr", dynlib: pdcursesdll.} -proc mvwaddch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwaddch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwaddch", dynlib: pdcursesdll.} -proc mvwaddnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwaddnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwaddnstr", dynlib: pdcursesdll.} -proc mvwaddstr*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwgetnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwgetnstr", dynlib: pdcursesdll.} -proc mvwgetstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. +proc mvwhline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. extdecl, importc: "mvwhline", dynlib: pdcursesdll.} -proc mvwinchnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwinchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwinchstr", dynlib: pdcursesdll.} -proc mvwinch*(a2: ptr TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinnstr", dynlib: pdcursesdll.} -proc mvwinsch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwinsch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwinsch", dynlib: pdcursesdll.} -proc mvwinsnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinsnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinsnstr", dynlib: pdcursesdll.} -proc mvwinsstr*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. +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 TWINDOW{.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 TSCREEN{.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 TWINDOW{.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 TWINDOW; 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 TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc notimeout*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "notimeout", dynlib: pdcursesdll.} -proc overlay*(a2: ptr TWINDOW; a3: ptr TWINDOW): cint{.extdecl, importc: "overlay", +proc overlay*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, importc: "overlay", dynlib: pdcursesdll.} -proc overwrite*(a2: ptr TWINDOW; a3: ptr TWINDOW): 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 TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc pechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "pechochar", dynlib: pdcursesdll.} -proc pnoutrefresh*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW): 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 (*)(TWINDOW *, int)); +#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 TWINDOW): cint{.extdecl, importc: "scroll", +proc scroll*(a2: ptr WINDOW): cint{.extdecl, importc: "scroll", dynlib: pdcursesdll.} -proc scrollok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc scrollok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "scrollok", dynlib: pdcursesdll.} -proc set_term*(a2: ptr TSCREEN): ptr TSCREEN{.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.} proc standout*(): cint{.extdecl, importc: "standout", dynlib: pdcursesdll.} proc start_color*(): cint{.extdecl, importc: "start_color", dynlib: pdcursesdll.} -proc subpad*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +proc subpad*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{. extdecl, importc: "subpad", dynlib: pdcursesdll.} -proc subwin*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +proc subwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{. extdecl, importc: "subwin", dynlib: pdcursesdll.} -proc syncok*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW): 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 TWINDOW): 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 TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwprintw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vw_printw", dynlib: pdcursesdll.} -proc vwprintw2*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwprintw2*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vwprintw", dynlib: pdcursesdll.} -proc vwscanw*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwscanw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vw_scanw", dynlib: pdcursesdll.} -proc vwscanw2*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwscanw2*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vwscanw", dynlib: pdcursesdll.} -proc waddchnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc waddchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "waddchstr", dynlib: pdcursesdll.} -proc waddch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch", +proc waddch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch", dynlib: pdcursesdll.} -proc waddnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cstring): cint{.extdecl, importc: "waddstr", +proc waddstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddstr", dynlib: pdcursesdll.} -proc wattroff*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattroff*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattroff", dynlib: pdcursesdll.} -proc wattron*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattron*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattron", dynlib: pdcursesdll.} -proc wattrset*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattrset*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattrset", dynlib: pdcursesdll.} -proc wattr_get*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cunsignedlong; a4: cshort; a5: pointer): cint{. +proc wattr_set*(a2: ptr WINDOW; a3: cunsignedlong; a4: cshort; a5: pointer): cint{. extdecl, importc: "wattr_set", dynlib: pdcursesdll.} -proc wbkgdset*(a2: ptr TWINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset", +proc wbkgdset*(a2: ptr WINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset", dynlib: pdcursesdll.} -proc wbkgd*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd", +proc wbkgd*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd", dynlib: pdcursesdll.} -proc wborder*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW): cint{.extdecl, importc: "wclear", +proc wclear*(a2: ptr WINDOW): cint{.extdecl, importc: "wclear", dynlib: pdcursesdll.} -proc wclrtobot*(a2: ptr TWINDOW): cint{.extdecl, importc: "wclrtobot", +proc wclrtobot*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtobot", dynlib: pdcursesdll.} -proc wclrtoeol*(a2: ptr TWINDOW): cint{.extdecl, importc: "wclrtoeol", +proc wclrtoeol*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtoeol", dynlib: pdcursesdll.} -proc wcolor_set*(a2: ptr TWINDOW; 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 TWINDOW){.extdecl, importc: "wcursyncup", +proc wcursyncup*(a2: ptr WINDOW){.extdecl, importc: "wcursyncup", dynlib: pdcursesdll.} -proc wdelch*(a2: ptr TWINDOW): cint{.extdecl, importc: "wdelch", +proc wdelch*(a2: ptr WINDOW): cint{.extdecl, importc: "wdelch", dynlib: pdcursesdll.} -proc wdeleteln*(a2: ptr TWINDOW): cint{.extdecl, importc: "wdeleteln", +proc wdeleteln*(a2: ptr WINDOW): cint{.extdecl, importc: "wdeleteln", dynlib: pdcursesdll.} -proc wechochar*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wechochar", dynlib: pdcursesdll.} -proc werase*(a2: ptr TWINDOW): cint{.extdecl, importc: "werase", +proc werase*(a2: ptr WINDOW): cint{.extdecl, importc: "werase", dynlib: pdcursesdll.} -proc wgetch*(a2: ptr TWINDOW): cint{.extdecl, importc: "wgetch", +proc wgetch*(a2: ptr WINDOW): cint{.extdecl, importc: "wgetch", dynlib: pdcursesdll.} -proc wgetnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr", +proc wgetstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr", dynlib: pdcursesdll.} -proc whline*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc winchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "winchstr", dynlib: pdcursesdll.} -proc winch*(a2: ptr TWINDOW): cunsignedlong{.extdecl, importc: "winch", +proc winch*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "winch", dynlib: pdcursesdll.} -proc winnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch", +proc winsch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch", dynlib: pdcursesdll.} -proc winsdelln*(a2: ptr TWINDOW; a3: cint): cint{.extdecl, importc: "winsdelln", +proc winsdelln*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "winsdelln", dynlib: pdcursesdll.} -proc winsertln*(a2: ptr TWINDOW): cint{.extdecl, importc: "winsertln", +proc winsertln*(a2: ptr WINDOW): cint{.extdecl, importc: "winsertln", dynlib: pdcursesdll.} -proc winsnstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: cstring): cint{.extdecl, importc: "winsstr", +proc winsstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winsstr", dynlib: pdcursesdll.} -proc winstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "winstr", +proc winstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winstr", dynlib: pdcursesdll.} -proc wmove*(a2: ptr TWINDOW; 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 TWINDOW): cint{.extdecl, importc: "wnoutrefresh", +proc wnoutrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wnoutrefresh", dynlib: pdcursesdll.} -proc wprintw*(a2: ptr TWINDOW; a3: cstring): cint{.varargs, extdecl, +proc wprintw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, importc: "wprintw", dynlib: pdcursesdll.} -proc wredrawln*(a2: ptr TWINDOW; 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 TWINDOW): cint{.extdecl, importc: "wrefresh", +proc wrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wrefresh", dynlib: pdcursesdll.} -proc wscanw*(a2: ptr TWINDOW; a3: cstring): cint{.varargs, extdecl, +proc wscanw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, importc: "wscanw", dynlib: pdcursesdll.} -proc wscrl*(a2: ptr TWINDOW; a3: cint): cint{.extdecl, importc: "wscrl", +proc wscrl*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "wscrl", dynlib: pdcursesdll.} -proc wsetscrreg*(a2: ptr TWINDOW; 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 TWINDOW): cint{.extdecl, importc: "wstandend", +proc wstandend*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandend", dynlib: pdcursesdll.} -proc wstandout*(a2: ptr TWINDOW): cint{.extdecl, importc: "wstandout", +proc wstandout*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandout", dynlib: pdcursesdll.} -proc wsyncdown*(a2: ptr TWINDOW){.extdecl, importc: "wsyncdown", +proc wsyncdown*(a2: ptr WINDOW){.extdecl, importc: "wsyncdown", dynlib: pdcursesdll.} -proc wsyncup*(a2: ptr TWINDOW){.extdecl, importc: "wsyncup", dynlib: pdcursesdll.} -proc wtimeout*(a2: ptr TWINDOW; a3: cint){.extdecl, importc: "wtimeout", +proc wsyncup*(a2: ptr WINDOW){.extdecl, importc: "wsyncup", dynlib: pdcursesdll.} +proc wtimeout*(a2: ptr WINDOW; a3: cint){.extdecl, importc: "wtimeout", dynlib: pdcursesdll.} -proc wtouchln*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong): cint{. +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.} -proc mvwaddnwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwaddnwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwaddnwstr", dynlib: pdcursesdll.} -proc mvwaddwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwaddwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwaddwstr", dynlib: pdcursesdll.} -proc mvwadd_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwadd_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwadd_wchstr", dynlib: pdcursesdll.} -proc mvwgetn_wstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cint; a6: cint): cint{. +proc mvwgetn_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint; a6: cint): cint{. extdecl, importc: "mvwgetn_wstr", dynlib: pdcursesdll.} -proc mvwget_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. +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 TWINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. +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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinnwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinnwstr", dynlib: pdcursesdll.} -proc mvwins_nwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwins_nwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwins_nwstr", dynlib: pdcursesdll.} -proc mvwins_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwins_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwins_wch", dynlib: pdcursesdll.} -proc mvwins_wstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwins_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwins_wstr", dynlib: pdcursesdll.} -proc mvwin_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwin_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwin_wchstr", dynlib: pdcursesdll.} -proc mvwinwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwinwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwinwstr", dynlib: pdcursesdll.} -proc mvwvline_set*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cstring): cint{.extdecl, +proc waddwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddwstr", dynlib: pdcursesdll.} -proc wadd_wch*(a2: ptr TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{. +proc wadd_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{. extdecl, importc: "wadd_wchnstr", dynlib: pdcursesdll.} -proc wadd_wchstr*(a2: ptr TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wbkgrnd", dynlib: pdcursesdll.} -proc wbkgrndset*(a2: ptr TWINDOW; a3: ptr cunsignedlong){.extdecl, +proc wbkgrndset*(a2: ptr WINDOW; a3: ptr cunsignedlong){.extdecl, importc: "wbkgrndset", dynlib: pdcursesdll.} -proc wborder_set*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wgetbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wgetbkgrnd", dynlib: pdcursesdll.} -proc wgetn_wstr*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cstring): cint{.extdecl, +proc wins_wstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wins_wstr", dynlib: pdcursesdll.} -proc winwstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "winwstr", +proc winwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winwstr", dynlib: pdcursesdll.} -proc win_wch*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW; 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 TWINDOW): cunsignedlong{.extdecl, importc: "getattrs", +proc getattrs*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getattrs", dynlib: pdcursesdll.} -proc getbegx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getbegx", +proc getbegx*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegx", dynlib: pdcursesdll.} -proc getbegy*(a2: ptr TWINDOW): cint{.extdecl, importc: "getbegy", +proc getbegy*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegy", dynlib: pdcursesdll.} -proc getmaxx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getmaxx", +proc getmaxx*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxx", dynlib: pdcursesdll.} -proc getmaxy*(a2: ptr TWINDOW): cint{.extdecl, importc: "getmaxy", +proc getmaxy*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxy", dynlib: pdcursesdll.} -proc getparx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getparx", +proc getparx*(a2: ptr WINDOW): cint{.extdecl, importc: "getparx", dynlib: pdcursesdll.} -proc getpary*(a2: ptr TWINDOW): cint{.extdecl, importc: "getpary", +proc getpary*(a2: ptr WINDOW): cint{.extdecl, importc: "getpary", dynlib: pdcursesdll.} -proc getcurx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getcurx", +proc getcurx*(a2: ptr WINDOW): cint{.extdecl, importc: "getcurx", dynlib: pdcursesdll.} -proc getcury*(a2: ptr TWINDOW): 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.} @@ -1351,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 TWINDOW; 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 TWINDOW; 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 TMEVENT): cint{.extdecl, importc: "nc_getmouse", +proc nc_getmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "nc_getmouse", dynlib: pdcursesdll.} -proc ungetmouse*(a2: ptr TMEVENT): cint{.extdecl, importc: "ungetmouse", +proc ungetmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "ungetmouse", dynlib: pdcursesdll.} -proc wenclose*(a2: ptr TWINDOW; 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 TWINDOW; a3: ptr cint; a4: ptr cint; a5: cunsignedchar): cunsignedchar{. +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 TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwaddrawch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwaddrawch", dynlib: pdcursesdll.} -proc mvwdeleteln*(a2: ptr TWINDOW; 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 TWINDOW; 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 TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +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 TWINDOW; a3: cint; a4: cint): ptr TWINDOW{.extdecl, +proc resize_window*(a2: ptr WINDOW; a3: cint; a4: cint): ptr WINDOW{.extdecl, importc: "resize_window", dynlib: pdcursesdll.} -proc waddrawch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc waddrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddrawch", dynlib: pdcursesdll.} -proc winsrawch*(a2: ptr TWINDOW; 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 TPANEL): cint{.extdecl, importc: "bottom_panel", +proc bottom_panel*(pan: ptr PANEL): cint{.extdecl, importc: "bottom_panel", dynlib: pdcursesdll.} -proc del_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "del_panel", +proc del_panel*(pan: ptr PANEL): cint{.extdecl, importc: "del_panel", dynlib: pdcursesdll.} -proc hide_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "hide_panel", +proc hide_panel*(pan: ptr PANEL): cint{.extdecl, importc: "hide_panel", dynlib: pdcursesdll.} -proc move_panel*(pan: ptr TPANEL; 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 TWINDOW): ptr TPANEL{.extdecl, importc: "new_panel", +proc new_panel*(win: ptr WINDOW): ptr PANEL{.extdecl, importc: "new_panel", dynlib: pdcursesdll.} -proc panel_above*(pan: ptr TPANEL): ptr TPANEL{.extdecl, importc: "panel_above", +proc panel_above*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_above", dynlib: pdcursesdll.} -proc panel_below*(pan: ptr TPANEL): ptr TPANEL{.extdecl, importc: "panel_below", +proc panel_below*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_below", dynlib: pdcursesdll.} -proc panel_hidden*(pan: ptr TPANEL): cint{.extdecl, importc: "panel_hidden", +proc panel_hidden*(pan: ptr PANEL): cint{.extdecl, importc: "panel_hidden", dynlib: pdcursesdll.} -proc panel_userptr*(pan: ptr TPANEL): pointer{.extdecl, importc: "panel_userptr", +proc panel_userptr*(pan: ptr PANEL): pointer{.extdecl, importc: "panel_userptr", dynlib: pdcursesdll.} -proc panel_window*(pan: ptr TPANEL): ptr TWINDOW{.extdecl, importc: "panel_window", +proc panel_window*(pan: ptr PANEL): ptr WINDOW{.extdecl, importc: "panel_window", dynlib: pdcursesdll.} -proc replace_panel*(pan: ptr TPANEL; win: ptr TWINDOW): cint{.extdecl, +proc replace_panel*(pan: ptr PANEL; win: ptr WINDOW): cint{.extdecl, importc: "replace_panel", dynlib: pdcursesdll.} -proc set_panel_userptr*(pan: ptr TPANEL; 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 TPANEL): cint{.extdecl, importc: "show_panel", +proc show_panel*(pan: ptr PANEL): cint{.extdecl, importc: "show_panel", dynlib: pdcursesdll.} -proc top_panel*(pan: ptr TPANEL): 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 TWINDOW{.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 = @@ -1519,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): @@ -1535,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", - dynlib: pdcursesdll.} \ No newline at end of file + 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 cb39c41bb..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 - TSockAddr* = array[1..112, int8] - TPGresAttDesc*{.pure, final.} = object +type + SockAddr* = array[1..112, int8] + PGresAttDesc*{.pure, final.} = object name*: cstring adtid*: Oid adtsize*: int - PPGresAttDesc* = ptr TPGresAttDesc + PPGresAttDesc* = ptr PGresAttDesc PPPGresAttDesc* = ptr PPGresAttDesc - TPGresAttValue*{.pure, final.} = object + PGresAttValue*{.pure, final.} = object length*: int32 value*: cstring - PPGresAttValue* = ptr TPGresAttValue + PPGresAttValue* = ptr PGresAttValue PPPGresAttValue* = ptr PPGresAttValue - PExecStatusType* = ptr TExecStatusType - TExecStatusType* = enum - PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, + PExecStatusType* = ptr ExecStatusType + 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 - TPGlobjfuncs*{.pure, final.} = object + PGlobjfuncs*{.pure, final.} = object fn_lo_open*: Oid fn_lo_close*: Oid fn_lo_creat*: Oid @@ -54,26 +63,26 @@ type fn_lo_read*: Oid fn_lo_write*: Oid - PPGlobjfuncs* = ptr TPGlobjfuncs - PConnStatusType* = ptr TConnStatusType - TConnStatusType* = enum - CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, - CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, + PPGlobjfuncs* = ptr PGlobjfuncs + PConnStatusType* = ptr ConnStatusType + ConnStatusType* = enum + CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, + CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, CONNECTION_SSL_STARTUP, CONNECTION_NEEDED - TPGconn*{.pure, final.} = object + PGconn*{.pure, final.} = object pghost*: cstring pgtty*: cstring pgport*: cstring pgoptions*: cstring dbName*: cstring - status*: TConnStatusType + status*: ConnStatusType errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char] Pfin*: File Pfout*: File Pfdebug*: File sock*: int32 - laddr*: TSockAddr - raddr*: TSockAddr + laddr*: SockAddr + raddr*: SockAddr salt*: array[0..(2) - 1, char] asyncNotifyWaiting*: int32 notifyList*: pointer @@ -81,32 +90,32 @@ type pgpass*: cstring lobjfuncs*: PPGlobjfuncs - PPGconn* = ptr TPGconn - TPGresult*{.pure, final.} = object + PPGconn* = ptr PGconn + PGresult*{.pure, final.} = object ntups*: int32 numAttributes*: int32 attDescs*: PPGresAttDesc tuples*: PPPGresAttValue tupArrSize*: int32 - resultStatus*: TExecStatusType + resultStatus*: ExecStatusType cmdStatus*: array[0..(CMDSTATUS_LEN) - 1, char] binary*: int32 conn*: PPGconn - PPGresult* = ptr TPGresult + 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,33 +148,36 @@ type dispsize*: int32 PPQArgBlock* = ptr PQArgBlock - PQArgBlock*{.pure, final.} = object + PQArgBlock*{.pure, final.} = object length*: int32 isint*: int32 p*: pointer +{.deprecated: [TSockAddr: SockAddr, TPGresAttDesc: PgresAttDesc, + TPGresAttValue: PgresAttValue, TExecStatusType: ExecStatusType, + 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".} @@ -173,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): TConnStatusType{.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, @@ -219,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): TExecStatusType{.cdecl, dynlib: dllName, +proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName, importc: "PQresultStatus".} -proc pqresStatus*(status: TExecStatusType): 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".} @@ -309,25 +321,25 @@ proc pqgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{. cdecl, dynlib: dllName, importc: "PQgetisnull".} proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".} proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".} -proc pqmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{. +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".} @@ -335,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 495bc15e4..000000000 --- a/lib/wrappers/readline/history.nim +++ /dev/null @@ -1,277 +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 - Thistdata* = pointer - -# The structure used to store a history entry. - -type - THIST_ENTRY*{.pure, final.} = object - line*: cstring - timestamp*: cstring # char * rather than time_t for read/write - data*: Thistdata - - -# 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 - THISTORY_STATE*{.pure, final.} = object - entries*: ptr ptr THIST_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 - - -# 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 THISTORY_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 THISTORY_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 THIST_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 THIST_ENTRY): Thistdata{.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: Thistdata): ptr THIST_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 THIST_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 THIST_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 THIST_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 THIST_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 THIST_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 THIST_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 5a319243e..000000000 --- a/lib/wrappers/readline/readline.nim +++ /dev/null @@ -1,1202 +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 "'TCommandFunc'" TCommandFunc -# 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 - TKEYMAP_ENTRY*{.pure, final.} = object - typ*: char - function*: TCommandFunc - - -# 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 - TKEYMAP_ENTRY_ARRAY* = array[0..KEYMAP_SIZE - 1, TKEYMAP_ENTRY] - PKeymap* = ptr TKEYMAP_ENTRY - -# 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.}: TKEYMAP_ENTRY_ARRAY - emacs_meta_keymap*{.importc: "emacs_meta_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - emacs_ctlx_keymap*{.importc: "emacs_ctlx_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - var - vi_insertion_keymap*{.importc: "vi_insertion_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - vi_movement_keymap*{.importc: "vi_movement_keymap", dynlib: readlineDll.}: TKEYMAP_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 - Thook_func* = proc (a2: cstring): cstring{.cdecl.} - -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.}: Thook_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.}: Thook_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 - Tundo_code* = enum - UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END - -# What an element of THE_UNDO_LIST looks like. - -type - TUNDO_LIST*{.pure, final.} = object - next*: ptr Tundo_list - start*: cint - theEnd*: cint # Where the change took place. - text*: cstring # The text to insert, if undoing a delete. - what*: Tundo_code # Delete, Insert, Begin, End. - - -# The current undo list for RL_LINE_BUFFER. - -when not defined(macosx): - var undo_list*{.importc: "rl_undo_list", dynlib: readlineDll.}: ptr TUNDO_LIST - -# The data structure for mapping textual names to code addresses. - -type - TFUNMAP*{.pure, final.} = object - name*: cstring - function*: TCommandFunc - - -when not defined(macosx): - var funmap*{.importc: "funmap", dynlib: readlineDll.}: ptr ptr TFUNMAP - -# **************************************************************** -# -# 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: TCommandFunc, a4: cint): cint{.cdecl, - importc: "rl_add_defun", dynlib: readlineDll.} -proc bind_key*(a2: cint, a3: TCommandFunc): cint{.cdecl, - importc: "rl_bind_key", dynlib: readlineDll.} -proc bind_key_in_map*(a2: cint, a3: TCommandFunc, 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: TCommandFunc): cint{.cdecl, - importc: "rl_bind_key_if_unbound", dynlib: readlineDll.} -proc bind_key_if_unbound_in_map*(a2: cint, a3: TCommandFunc, a4: PKeymap): cint{. - cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.} -proc unbind_function_in_map*(a2: TCommandFunc, 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: TCommandFunc): cint{.cdecl, - importc: "rl_bind_keyseq", dynlib: readlineDll.} -proc bind_keyseq_in_map*(a2: cstring, a3: TCommandFunc, a4: PKeymap): cint{. - cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.} -proc bind_keyseq_if_unbound*(a2: cstring, a3: TCommandFunc): cint{.cdecl, - importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.} -proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: TCommandFunc, - 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: TCommandFunc, 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): TCommandFunc{.cdecl, - importc: "rl_named_function", dynlib: readlineDll.} -proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): TCommandFunc{. - 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: TCommandFunc, a3: PKeymap): cstringArray{. - cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.} -proc invoking_keyseqs*(a2: TCommandFunc): 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: TCommandFunc): 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: Tundo_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: Tcompentry_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: TCommandFunc): 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.}: TCommandFunc - # 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 - Treadline_state*{.pure, final.} = object - point*: cint # line state - theEnd*: cint - mark*: cint - buffer*: cstring - buflen*: cint - ul*: ptr TUNDO_LIST - prompt*: cstring # global state - rlstate*: cint - done*: cint - kmap*: PKeymap # input state - lastfunc*: TCommandFunc - 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] - - -proc save_state*(a2: ptr Treadline_state): cint{.cdecl, - importc: "rl_save_state", dynlib: readlineDll.} -proc restore_state*(a2: ptr Treadline_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 847834e80..000000000 --- a/lib/wrappers/readline/rltypedefs.nim +++ /dev/null @@ -1,74 +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 - TFunction* = proc (): cint{.cdecl.} - TVFunction* = proc (){.cdecl.} - TCPFunction* = proc (): cstring{.cdecl.} - TCPPFunction* = proc (): cstringArray{.cdecl.} - -# Bindable functions - -type - Tcommand_func* = proc (a2: cint, a3: cint): cint{.cdecl.} - -# Typedefs for the completion system - -type - Tcompentry_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} - Tcompletion_func* = proc (a2: cstring, a3: cint, a4: cint): cstringArray{. - cdecl.} - Tquote_func* = proc (a2: cstring, a3: cint, a4: cstring): cstring{.cdecl.} - Tdequote_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} - Tcompignore_func* = proc (a2: cstringArray): cint{.cdecl.} - Tcompdisp_func* = proc (a2: cstringArray, a3: cint, a4: cint){.cdecl.} - -# 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 5bb5b7ec2..000000000 --- a/lib/wrappers/sdl/sdl.nim +++ /dev/null @@ -1,2538 +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 - TEventKind* = 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 - -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 - THandle* = int #SDL_types.h types - # Basic data types - TBool* = enum - sdlFALSE, sdlTRUE - PUInt8Array* = ptr TUInt8Array - TUInt8Array* = 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 - - TGrabMode* = int32 # SDL_error.h types - Terrorcode* = enum - ENOMEM, EFREAD, EFWRITE, EFSEEK, LASTERROR - Errorcode* = Terrorcode - TArg*{.final.} = object - buf*: array[0..ERR_MAX_STRLEN - 1, int8] - - Perror* = ptr Terror - TError*{.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, TArg] - - TStdio*{.final.} = object - autoclose*: int # FILE * is only defined in Kylix so we use a simple pointer - fp*: pointer - - TMem*{.final.} = object - base*: ptr byte - here*: ptr byte - stop*: ptr byte - - PRWops* = ptr TRWops # now the pointer to function types - TSeek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.} - TRead* = proc (context: PRWops, thePtr: pointer, size: int, maxnum: int): int{. - cdecl.} - TWrite* = proc (context: PRWops, thePtr: pointer, size: int, num: int): int{. - cdecl.} - TClose* = proc (context: PRWops): int{.cdecl.} # the variant record itself - TRWops*{.final.} = object - seek*: TSeek - read*: TRead - write*: TWrite - closeFile*: TClose # a keyword as name is not allowed - # be warned! structure alignment may arise at this point - theType*: cint - mem*: TMem - - RWops* = TRWops # SDL_timer.h types - # Function prototype for the timer callback function - TTimerCallback* = proc (interval: int32): int32{.cdecl.} - TNewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.} - - PTimerID* = ptr TTimerID - TTimerID*{.final.} = object - interval*: int32 - callback*: TNewTimerCallback - param*: pointer - lastAlarm*: int32 - next*: PTimerID - - TAudioSpecCallback* = 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 TAudioSpec - TAudioSpec*{.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*: TAudioSpecCallback - userdata*: pointer - - PAudioCVT* = ptr TAudioCVT - PAudioCVTFilter* = ptr TAudioCVTFilter - TAudioCVTFilter*{.final.} = object - cvt*: PAudioCVT - format*: uint16 - - PAudioCVTFilterArray* = ptr TAudioCVTFilterArray - TAudioCVTFilterArray* = array[0..9, PAudioCVTFilter] - TAudioCVT*{.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*: TAudioCVTFilterArray - filterIndex*: int # Current audio conversion function - - TAudiostatus* = enum # SDL_cdrom.h types - AUDIO_STOPPED, AUDIO_PLAYING, AUDIO_PAUSED - TCDStatus* = enum - CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED - PCDTrack* = ptr TCDTrack - TCDTrack*{.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 TCD - TCD*{.final.} = object #SDL_joystick.h types - id*: int # Private drive identifier - status*: TCDStatus # 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, TCDTrack] - - PTransAxis* = ptr TTransAxis - TTransAxis*{.final.} = object # The private structure used to keep track of a joystick - offset*: int - scale*: float32 - - PJoystickHwdata* = ptr TJoystickHwdata - TJoystick_hwdata*{.final.} = object # joystick ID - id*: int # values used to translate device-specific coordinates into SDL-standard ranges - transaxis*: array[0..5, TTransAxis] - - PBallDelta* = ptr TBallDelta - TBallDelta*{.final.} = object # Current ball motion deltas - # The SDL joystick structure - dx*: int - dy*: int - - PJoystick* = ptr TJoystick - TJoystick*{.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 Tversion - Tversion*{.final.} = object # SDL_keyboard.h types - major*: byte - minor*: byte - patch*: byte - - TKey* = int32 - TMod* = int32 - PKeySym* = ptr TKeySym - TKeySym*{.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*: TKey # SDL virtual keysym - modifier*: TMod # current key modifiers - unicode*: uint16 # translated character - - TEventAction* = enum # Application visibility event structure - ADDEVENT, PEEKEVENT, GETEVENT - - PActiveEvent* = ptr TActiveEvent - TActiveEvent*{.final.} = object # SDL_ACTIVEEVENT - # Keyboard event structure - kind*: TEventKind - gain*: byte # Whether given states were gained or lost (1/0) - state*: byte # A mask of the focus states - - PKeyboardEvent* = ptr TKeyboardEvent - TKeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP - # Mouse motion event structure - kind*: TEventKind - which*: byte # The keyboard device index - state*: byte # SDL_PRESSED or SDL_RELEASED - keysym*: TKeySym - - PMouseMotionEvent* = ptr TMouseMotionEvent - TMouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION - # Mouse button event structure - kind*: TEventKind - 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 TMouseButtonEvent - TMouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP - # Joystick axis motion event structure - kind*: TEventKind - 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 TJoyAxisEvent - TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION - # Joystick trackball motion event structure - kind*: TEventKind - which*: byte # The joystick device index - axis*: byte # The joystick axis index - value*: int16 # The axis value (range: -32768 to 32767) - - PJoyBallEvent* = ptr TJoyBallEvent - TJoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION - # Joystick hat position change event structure - kind*: TEventKind - 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 TJoyHatEvent - TJoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */ - # Joystick button event structure - kind*: TEventKind - 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 TJoyButtonEvent - TJoyButtonEvent*{.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*: TEventKind - which*: byte # The joystick device index - button*: byte # The joystick button index - state*: byte # SDL_PRESSED or SDL_RELEASED - - PResizeEvent* = ptr TResizeEvent - TResizeEvent*{.final.} = object # SDL_VIDEORESIZE - # A user-defined event type - kind*: TEventKind - w*: cint # New width - h*: cint # New height - - PUserEvent* = ptr TUserEvent - TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1 - kind*: TEventKind - code*: cint # User defined event code - data1*: pointer # User defined data pointer - data2*: pointer # User defined data pointer - - -when defined(Unix): - type #These are the various supported subsystems under UNIX - TSysWm* = enum - SYSWM_X11 -when defined(WINDOWS): - type - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion - hwnd*: THandle # The window for the message - msg*: int # The type of message - wParam*: int32 # WORD message parameter - lParam*: int32 # LONG message parameter - -elif defined(Unix): - type # The Linux custom event structure - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion - subsystem*: TSysWm - when false: - event*: TXEvent - - -else: - type # The generic custom event structure - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion - data*: int - -# The Windows custom window manager information structure - -when defined(WINDOWS): - type - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion - window*: THandle # The display window - -elif defined(Unix): - type - TX11*{.final.} = object - when false: - display*: PDisplay # The X11 display - window*: TWindow # 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*: TWindow # The X11 fullscreen window - wmwindow*: TWindow # The X11 managed input window - - - type - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion - subsystem*: TSysWm - X11*: TX11 - -else: - type # The generic custom window manager information structure - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion - data*: int - -type - PSysWMEvent* = ptr TSysWMEvent - TSysWMEvent*{.final.} = object - kind*: TEventKind - msg*: PSysWMmsg - - PExposeEvent* = ptr TExposeEvent - TExposeEvent*{.final.} = object - kind*: TEventKind - - PQuitEvent* = ptr TQuitEvent - TQuitEvent*{.final.} = object - kind*: TEventKind - - PEvent* = ptr TEvent - TEvent*{.final.} = object - kind*: TEventKind - pad: array[0..19, byte] - - TEventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types - # Useful data types - PPSDL_Rect* = ptr PRect - PRect* = ptr TRect - TRect*{.final.} = object - x*, y*: int16 - w*, h*: uint16 - - Rect* = TRect - PColor* = ptr TColor - TColor*{.final.} = object - r*: byte - g*: byte - b*: byte - unused*: byte - - PColorArray* = ptr TColorArray - TColorArray* = array[0..65000, TColor] - PPalette* = ptr TPalette - TPalette*{.final.} = object # Everything in the pixel format structure is read-only - ncolors*: int - colors*: PColorArray - - PPixelFormat* = ptr TPixelFormat - TPixelFormat*{.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 TBlitInfo - TBlitInfo*{.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 TSurface - TBlit* = proc (src: PSurface, srcrect: PRect, - dst: PSurface, dstrect: PRect): int{.cdecl.} - TSurface*{.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*: TRect # 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 TVideoInfo - TVideoInfo*{.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 TOverlay - TOverlay*{.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. - - TGLAttr* = 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 TCursor - TCursor*{.final.} = object # SDL_mutex.h types - area*: TRect # 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 - - -type - PMutex* = ptr TMutex - TMutex*{.final.} = object - Psemaphore* = ptr Tsemaphore - Tsemaphore*{.final.} = object - PSem* = ptr TSem - TSem* = Tsemaphore - PCond* = ptr TCond - TCond*{.final.} = object # SDL_thread.h types - -when defined(WINDOWS): - type - TSYS_ThreadHandle* = THandle -when defined(Unix): - type - TSYS_ThreadHandle* = pointer -type # This is the system-independent thread info structure - PThread* = ptr TThread - TThread*{.final.} = object # Helper Types - # Keyboard State Array ( See demos for how to use ) - threadid*: int32 - handle*: TSYS_ThreadHandle - status*: int - errbuf*: Terror - data*: pointer - - PKeyStateArr* = ptr TKeyStateArr - TKeyStateArr* = 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 TByteArray - TByteArray* = array[0..32767, int8] - PWordArray* = ptr TWordArray - TWordArray* = array[0..16383, int16] # Generic procedure pointer - -type TEventSeq = set[TEventKind] -template evconv(procName: expr, ptrName: typedesc, assertions: TEventSeq): 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: Terrorcode){.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: TNewTimerCallback, 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): TBool{.cdecl, importc: "SDL_RemoveTimer", - dynlib: LibName.} -proc setTimer*(interval: int32, callback: TTimerCallback): 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*(): TAudiostatus{.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): TCDStatus{.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: TCDStatus): 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: TEventAction, - 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: TEventFilter){.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*(): TEventFilter{.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 Tversion) - # 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: TGLAttr, 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: TGLAttr, 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: TGrabMode): TGrabMode{.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*(): TMod{.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: TMod){.cdecl, importc: "SDL_SetModState", - dynlib: LibName.} - # Get the name of an SDL virtual keysym -proc getKeyName*(key: TKey): 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: TCDStatus): 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 Tversion) = - 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 5523ad0a2..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 TFPSmanager - TFPSmanager*{.final.} = object # ---- Structures - framecount*: uint32 - rateticks*: float32 - lastticks*: uint32 - rate*: uint32 - - PColorRGBA* = ptr TColorRGBA - TColorRGBA*{.final.} = object - r*: byte - g*: byte - b*: byte - a*: byte - - PColorY* = ptr TColorY - TColorY*{.final.} = object # - # - # SDL_framerate: framerate manager - # - # LGPL (c) A. Schiffler - # - # - y*: byte - - -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 9c56e6a46..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 Tversion) - # 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 Tversion) = - 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 2f8664635..000000000 --- a/lib/wrappers/sdl/sdl_mixer.nim +++ /dev/null @@ -1,484 +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 TMusicCMD - TMusicCMD*{.final.} = object #wavestream.h types - filename*: array[0..PATH_MAX - 1, char] - cmd*: array[0..PATH_MAX - 1, char] - pid*: TSYS_ThreadHandle - - PWAVStream* = ptr TWAVStream - TWAVStream*{.final.} = object #playmidi.h types - wavefp*: pointer - start*: int32 - stop*: int32 - cvt*: TAudioCVT - - PMidiEvent* = ptr TMidiEvent - TMidiEvent*{.final.} = object - time*: int32 - channel*: byte - typ*: byte - a*: byte - b*: byte - - PMidiSong* = ptr TMidiSong - TMidiSong*{.final.} = object #music_ogg.h types - samples*: int32 - events*: PMidiEvent - - POGG_Music* = ptr TOGG_Music - TOGG_Music*{.final.} = object # mikmod.h types - #* - # * Error codes - # * - playing*: int32 - volume*: int32 #vf: OggVorbis_File; - section*: int32 - cvt*: TAudioCVT - lenAvailable*: int32 - sndAvailable*: pointer - - TErrorEnum* = 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 TMODULE - TMODULE*{.final.} = object - PUNIMOD* = ptr TUNIMOD - TUNIMOD* = TMODULE #SDL_mixer.h types - # The internal format for an audio chunk - PChunk* = ptr TChunk - TChunk*{.final.} = object - allocated*: cint - abuf*: pointer - alen*: uint32 - volume*: byte # Per-sample volume, 0-128 - - TFading* = enum - MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN - TMusicType* = enum - MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3 - PMusic* = ptr TMusic - TMusic*{.final.} = object # The internal format for a music chunk interpreted via mikmod - mixtype*: TMusicType # other fields are not aviable - # data : TMusicUnion; - # fading : TMix_Fading; - # fade_volume : integer; - # fade_step : integer; - # fade_steps : integer; - # error : integer; - - TMixFunction* = 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. - -proc version*(x: var sdl.Tversion) - # 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): TMusicType{.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: TMixFunction, 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: TMixFunction, 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 - TChannelFinished* = proc (channel: cint){.cdecl.} - -proc channelFinished*(channelFinished: TChannelFinished){.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*(): TFading{.cdecl, importc: "Mix_FadingMusic", - dynlib: MixerLibName.} -proc fadingChannel*(which: cint): TFading{.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.Tversion) = - 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 7a8c41af1..000000000 --- a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim +++ /dev/null @@ -1,351 +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 TMusicCMD - TMusicCMD*{.final.} = object #wavestream.h types - filename*: array[0..PATH_MAX - 1, char] - cmd*: array[0..PATH_MAX - 1, char] - pid*: TSYS_ThreadHandle - - PWAVStream* = ptr TWAVStream - TWAVStream*{.final.} = object #playmidi.h types - wavefp*: pointer - start*: int32 - stop*: int32 - cvt*: TAudioCVT - - PMidiEvent* = ptr TMidiEvent - TMidiEvent*{.final.} = object - time*: int32 - channel*: byte - typ*: byte - a*: byte - b*: byte - - PMidiSong* = ptr TMidiSong - TMidiSong*{.final.} = object #music_ogg.h types - samples*: int32 - events*: PMidiEvent - - POGG_Music* = ptr TOGG_Music - TOGG_Music*{.final.} = object # mikmod.h types - #* - # * Error codes - # * - playing*: cint - volume*: cint #vf: OggVorbis_File; - section*: cint - cvt*: TAudioCVT - lenAvailable*: cint - sndAvailable*: pointer - - TErrorEnum* = 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 TMODULE - TMODULE*{.final.} = object - PUNIMOD* = ptr TUNIMOD - TUNIMOD* = TMODULE #SDL_mixer.h types - # The internal format for an audio chunk - PChunk* = ptr TChunk - TChunk*{.final.} = object - allocated*: cint - abuf*: pointer - alen*: uint32 - volume*: byte # Per-sample volume, 0-128 - - TFading* = enum - MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN - TMusicType* = enum - MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG - PMusic* = ptr TMusic - TMusic*{.final.} = object - typ*: TMusicType - - TMixFunction* = 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. - -proc version*(x: var sdl.Tversion) - # 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): TMusicType{.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: TMixFunction, 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: TMixFunction, 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 - TChannelFinished* = proc (channel: cint){.cdecl.} - -proc channelFinished*(channelFinished: TChannelFinished){.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*(): TFading{.cdecl, importc: "Mix_FadingMusic", - dynlib: MixerLibName.} -proc fadingChannel*(which: cint): TFading{.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 Tversion) = - 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 1ffdb5cca..000000000 --- a/lib/wrappers/sdl/sdl_net.nim +++ /dev/null @@ -1,426 +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 TIPAddress - TIPAddress*{.final.} = object #* TCP network API - host*: uint32 # 32-bit IPv4 host address */ - port*: uint16 # 16-bit protocol port */ - - PTCPSocket* = ptr TTCPSocket - TTCPSocket*{.final.} = object # UDP network API - ready*: int - channel*: int - remoteAddress*: TIPAddress - localAddress*: TIPAddress - sflag*: int - - PUDP_Channel* = ptr TUDP_Channel - TUDP_Channel*{.final.} = object - numbound*: int - address*: array[0..MAX_UDPADDRESSES - 1, TIPAddress] - - PUDPSocket* = ptr TUDPSocket - TUDPSocket*{.final.} = object - ready*: int - channel*: int - address*: TIPAddress - binding*: array[0..MAX_UDPCHANNELS - 1, TUDP_Channel] - - PUDPpacket* = ptr TUDPpacket - PPUDPpacket* = ptr PUDPpacket - TUDPpacket*{.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*: TIPAddress #* The source/dest address of an incoming/outgoing packet * - - PSocket* = ptr TSocket - TSocket*{.final.} = object - ready*: int - channel*: int - - PSocketSet* = ptr TSocketSet - TSocketSet*{.final.} = object # Any network socket can be safely cast to this socket type * - numsockets*: int - maxsockets*: int - sockets*: PSocket - - PGenericSocket* = ptr TGenericSocket - TGenericSocket*{.final.} = object - ready*: int - - -proc version*(x: var Tversion) - #* 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 TIPAddress, 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 TIPAddress): 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 TIPAddress): 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 TIPAddress): 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 Tversion) = - 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 9ebe70b9d..000000000 --- a/lib/wrappers/sdl/sdl_ttf.nim +++ /dev/null @@ -1,337 +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 TFont - TFont = object - - -# 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: TColor): PSurface{. - cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.} -proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: TColor): 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: TColor): 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: TColor, - bg: TColor): PSurface{.cdecl, - importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.} -proc renderUTF8Shaded*(font: PFont, text: cstring, fg: TColor, - bg: TColor): PSurface{.cdecl, - importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.} -proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: TColor, - bg: TColor): 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: TColor, bg: TColor): 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: TColor): PSurface{. - cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.} -proc renderUTF8Blended*(font: PFont, text: cstring, fg: TColor): PSurface{. - cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.} -proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: TColor): 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: TColor): 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.Tversion) = - x.major = MAJOR_VERSION - x.minor = MINOR_VERSION - x.patch = PATCHLEVEL - - -proc renderTextSolid*(font: PFont, text: cstring, fg: TColor): 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 318c0b3df..000000000 --- a/lib/wrappers/sdl/smpeg.nim +++ /dev/null @@ -1,332 +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 - TFilterInfo*{.final.} = object - yuvMbSquareError*: PUInt16 - yuvPixelSquareError*: PUInt16 - - PFilterInfo* = ptr TFilterInfo # MPEG filter definition - PFilter* = ptr TFilter # Callback functions for the filter - TFilterCallback* = proc (dest, source: POverlay, region: PRect, - filterInfo: PFilterInfo, data: pointer): pointer{. - cdecl.} - TFilterDestroy* = proc (filter: PFilter): pointer{.cdecl.} # The filter definition itself - TFilter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay. - flags*: uint32 - data*: pointer - callback*: TFilterCallback - destroy*: TFilterDestroy - - -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 - TInfo* = 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 TInfo # Possible MPEG status codes - -const - STATUS_ERROR* = - 1 - STATUS_STOPPED* = 0 - STATUS_PLAYING* = 1 - -type - Tstatus* = 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. - -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): Tstatus{.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 e4a282968..000000000 --- a/lib/wrappers/sphinx.nim +++ /dev/null @@ -1,261 +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 - TSphinxBool* {.size: sizeof(cint).} = enum - SPH_FALSE = 0, - SPH_TRUE = 1 - - Tclient {.pure, final.} = object - PClient* = ptr TClient - Twordinfo*{.pure, final.} = object - word*: cstring - docs*: cint - hits*: cint - - Tresult*{.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, TWordinfo] - - Texcerpt_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*: TSphinxBool - single_passage*: TSphinxBool - use_boundaries*: TSphinxBool - weight_order*: TSphinxBool - query_mode*: TSphinxBool - force_all_words*: TSphinxBool - load_files*: TSphinxBool - allow_empty*: TSphinxBool - emit_zones*: TSphinxBool - - Tkeyword_info*{.pure, final.} = object - tokenized*: cstring - normalized*: cstring - num_docs*: cint - num_hits*: cint - - -proc create*(copy_args: TSphinxBool): 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): TSphinxBool{.cdecl, - importc: "sphinx_set_server", dynlib: sphinxDll.} -proc set_connect_timeout*(client: PClient, seconds: float32): TSphinxBool{.cdecl, - importc: "sphinx_set_connect_timeout", dynlib: sphinxDll.} -proc open*(client: PClient): TSphinxBool{.cdecl, importc: "sphinx_open", - dynlib: sphinxDll.} -proc close*(client: PClient): TSphinxBool{.cdecl, importc: "sphinx_close", - dynlib: sphinxDll.} -proc set_limits*(client: PClient, offset: cint, limit: cint, - max_matches: cint, cutoff: cint): TSphinxBool{.cdecl, - importc: "sphinx_set_limits", dynlib: sphinxDll.} -proc set_max_query_time*(client: PClient, max_query_time: cint): TSphinxBool{. - cdecl, importc: "sphinx_set_max_query_time", dynlib: sphinxDll.} -proc set_match_mode*(client: PClient, mode: cint): TSphinxBool{.cdecl, - importc: "sphinx_set_match_mode", dynlib: sphinxDll.} -proc set_ranking_mode*(client: PClient, ranker: cint): TSphinxBool{.cdecl, - importc: "sphinx_set_ranking_mode", dynlib: sphinxDll.} -proc set_sort_mode*(client: PClient, mode: cint, sortby: cstring): TSphinxBool{. - cdecl, importc: "sphinx_set_sort_mode", dynlib: sphinxDll.} -proc set_field_weights*(client: PClient, num_weights: cint, - field_names: cstringArray, field_weights: ptr cint): TSphinxBool{. - cdecl, importc: "sphinx_set_field_weights", dynlib: sphinxDll.} -proc set_index_weights*(client: PClient, num_weights: cint, - index_names: cstringArray, index_weights: ptr cint): TSphinxBool{. - cdecl, importc: "sphinx_set_index_weights", dynlib: sphinxDll.} -proc set_id_range*(client: PClient, minid: int64, maxid: int64): TSphinxBool{. - cdecl, importc: "sphinx_set_id_range", dynlib: sphinxDll.} -proc add_filter*(client: PClient, attr: cstring, num_values: cint, - values: ptr int64, exclude: TSphinxBool): TSphinxBool{.cdecl, - importc: "sphinx_add_filter", dynlib: sphinxDll.} -proc add_filter_range*(client: PClient, attr: cstring, umin: int64, - umax: int64, exclude: TSphinxBool): TSphinxBool{.cdecl, - importc: "sphinx_add_filter_range", dynlib: sphinxDll.} -proc add_filter_float_range*(client: PClient, attr: cstring, fmin: float32, - fmax: float32, exclude: TSphinxBool): TSphinxBool{.cdecl, - importc: "sphinx_add_filter_float_range", dynlib: sphinxDll.} -proc set_geoanchor*(client: PClient, attr_latitude: cstring, - attr_longitude: cstring, latitude: float32, longitude: float32): TSphinxBool{. - cdecl, importc: "sphinx_set_geoanchor", dynlib: sphinxDll.} -proc set_groupby*(client: PClient, attr: cstring, groupby_func: cint, - group_sort: cstring): TSphinxBool{.cdecl, - importc: "sphinx_set_groupby", dynlib: sphinxDll.} -proc set_groupby_distinct*(client: PClient, attr: cstring): TSphinxBool{.cdecl, - importc: "sphinx_set_groupby_distinct", dynlib: sphinxDll.} -proc set_retries*(client: PClient, count: cint, delay: cint): TSphinxBool{.cdecl, - importc: "sphinx_set_retries", dynlib: sphinxDll.} -proc add_override*(client: PClient, attr: cstring, docids: ptr int64, - num_values: cint, values: ptr cint): TSphinxBool{.cdecl, - importc: "sphinx_add_override", dynlib: sphinxDll.} -proc set_select*(client: PClient, select_list: cstring): TSphinxBool{.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 Tresult{.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 Tresult{.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 Tresult, match: cint): int64{.cdecl, - importc: "sphinx_get_id", dynlib: sphinxDll.} -proc get_weight*(result: ptr Tresult, match: cint): cint{.cdecl, - importc: "sphinx_get_weight", dynlib: sphinxDll.} -proc get_int*(result: ptr Tresult, match: cint, attr: cint): int64{.cdecl, - importc: "sphinx_get_int", dynlib: sphinxDll.} -proc get_float*(result: ptr Tresult, match: cint, attr: cint): float32{.cdecl, - importc: "sphinx_get_float", dynlib: sphinxDll.} -proc get_mva*(result: ptr Tresult, match: cint, attr: cint): ptr cint{. - cdecl, importc: "sphinx_get_mva", dynlib: sphinxDll.} -proc get_string*(result: ptr Tresult, match: cint, attr: cint): cstring{.cdecl, - importc: "sphinx_get_string", dynlib: sphinxDll.} -proc init_excerpt_options*(opts: ptr Texcerpt_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 Texcerpt_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: TSphinxBool, out_num_keywords: ptr cint): ptr Tkeyword_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/sqlite3.nim b/lib/wrappers/sqlite3.nim index e3a3fa0b8..bd107b0bc 100644 --- a/lib/wrappers/sqlite3.nim +++ b/lib/wrappers/sqlite3.nim @@ -13,7 +13,7 @@ when defined(windows): Lib = "sqlite3.dll" elif defined(macosx): const - Lib = "(libsqlite3(|.0).dylib|sqlite-3.6.13.dylib)" + Lib = "libsqlite3(|.0).dylib" else: const Lib = "libsqlite3.so(|.0)" @@ -97,33 +97,39 @@ const SQLITE_TRANSIENT* = cast[pointer](- 1) type - TSqlite3 {.pure, final.} = object - PSqlite3* = ptr TSqlite3 + Sqlite3 {.pure, final.} = object + PSqlite3* = ptr Sqlite3 PPSqlite3* = ptr PSqlite3 - TContext{.pure, final.} = object - Pcontext* = ptr TContext + Context{.pure, final.} = object + Pcontext* = ptr Context Tstmt{.pure, final.} = object Pstmt* = ptr Tstmt - Tvalue{.pure, final.} = object - Pvalue* = ptr Tvalue + Value{.pure, final.} = object + Pvalue* = ptr Value PValueArg* = array[0..127, Pvalue] - Tcallback* = proc (para1: pointer, para2: int32, para3, + Callback* = proc (para1: pointer, para2: int32, para3, para4: cstringArray): int32{.cdecl.} Tbind_destructor_func* = proc (para1: pointer){.cdecl.} - Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32, + Create_function_step_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} - Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32, + Create_function_func_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} - Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.} - Tresult_func* = proc (para1: pointer){.cdecl.} - Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, + Create_function_final_func* = proc (para1: Pcontext){.cdecl.} + Result_func* = proc (para1: pointer){.cdecl.} + Create_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, para4: int32, para5: pointer): int32{.cdecl.} - Tcollation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, + Collation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, para4: cstring){.cdecl.} +{.deprecated: [TSqlite3: Sqlite3, TContext: Context, Tvalue: Value, + Tcallback: Callback, Tcreate_function_step_func: Create_function_step_func, + Tcreate_function_func_func: Create_function_func_func, + Tcreate_function_final_func: Create_function_final_func, + Tresult_func: Result_func, Tcreate_collation_func: Create_collation_func, + Tcollation_needed_func: Collation_needed_func].} proc close*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_close".} -proc exec*(para1: PSqlite3, sql: cstring, para3: Tcallback, para4: pointer, +proc exec*(para1: PSqlite3, sql: cstring, para3: Callback, para4: pointer, errmsg: var cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_exec".} proc last_insert_rowid*(para1: PSqlite3): int64{.cdecl, dynlib: Lib, @@ -261,15 +267,15 @@ proc finalize*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, proc reset*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_reset".} proc create_function*(para1: PSqlite3, zFunctionName: cstring, nArg: int32, eTextRep: int32, para5: pointer, - xFunc: Tcreate_function_func_func, - xStep: Tcreate_function_step_func, - xFinal: Tcreate_function_final_func): int32{.cdecl, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function".} proc create_function16*(para1: PSqlite3, zFunctionName: pointer, nArg: int32, eTextRep: int32, para5: pointer, - xFunc: Tcreate_function_func_func, - xStep: Tcreate_function_step_func, - xFinal: Tcreate_function_final_func): int32{.cdecl, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function16".} proc aggregate_count*(para1: Pcontext): int32{.cdecl, dynlib: Lib, importc: "sqlite3_aggregate_count".} @@ -305,7 +311,7 @@ proc set_auxdata*(para1: Pcontext, para2: int32, para3: pointer, para4: proc (para1: pointer){.cdecl.}){.cdecl, dynlib: Lib, importc: "sqlite3_set_auxdata".} proc result_blob*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_blob".} proc result_double*(para1: Pcontext, para2: float64){.cdecl, dynlib: Lib, importc: "sqlite3_result_double".} @@ -320,28 +326,28 @@ proc result_int64*(para1: Pcontext, para2: int64){.cdecl, dynlib: Lib, proc result_null*(para1: Pcontext){.cdecl, dynlib: Lib, importc: "sqlite3_result_null".} proc result_text*(para1: Pcontext, para2: cstring, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text".} proc result_text16*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16".} proc result_text16le*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16le".} proc result_text16be*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16be".} proc result_value*(para1: Pcontext, para2: Pvalue){.cdecl, dynlib: Lib, importc: "sqlite3_result_value".} proc create_collation*(para1: PSqlite3, zName: cstring, eTextRep: int32, - para4: pointer, xCompare: Tcreate_collation_func): int32{. + para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation".} proc create_collation16*(para1: PSqlite3, zName: cstring, eTextRep: int32, - para4: pointer, xCompare: Tcreate_collation_func): int32{. + para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation16".} -proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Tcollation_needed_func): int32{. +proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_collation_needed".} -proc collation_needed16*(para1: PSqlite3, para2: pointer, para3: Tcollation_needed_func): int32{. +proc collation_needed16*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_collation_needed16".} proc libversion*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".} #Alias for allowing better code portability (win32 is not working with external variables) diff --git a/lib/wrappers/tinyc.nim b/lib/wrappers/tinyc.nim index ac6cb70f1..05c65b12f 100644 --- a/lib/wrappers/tinyc.nim +++ b/lib/wrappers/tinyc.nim @@ -8,10 +8,11 @@ # type - TccState {.pure, final.} = object - PccState* = ptr TccState + CcState {.pure, final.} = object + PccState* = ptr CcState - TErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.} + ErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.} +{.deprecated: [TccState: CcState, TErrorFunc: ErrorFunc].} proc openCCState*(): PccState {.importc: "tcc_new", cdecl.} ## create a new TCC compilation context @@ -22,7 +23,7 @@ proc closeCCState*(s: PccState) {.importc: "tcc_delete", cdecl.} proc enableDebug*(s: PccState) {.importc: "tcc_enable_debug", cdecl.} ## add debug information in the generated code -proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: TErrorFunc) {. +proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: ErrorFunc) {. cdecl, importc: "tcc_set_error_func".} ## set error/warning display callback diff --git a/lib/wrappers/tre.nim b/lib/wrappers/tre.nim deleted file mode 100644 index 92cd16333..000000000 --- a/lib/wrappers/tre.nim +++ /dev/null @@ -1,186 +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 - TRegoff* = cint - TRegex*{.pure, final.} = object - re_nsub*: int ## Number of parenthesized subexpressions. - value*: pointer ## For internal use only. - - TRegmatch*{.pure, final.} = object - rm_so*: TRegoff - rm_eo*: TRegoff - - TReg_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. - -# 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 TRegex, regex: cstring, cflags: cint): cint{.cdecl, - importc: "tre_regcomp", dynlib: treDll.} -proc regexec*(preg: var TRegex, string: cstring, nmatch: int, - pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, - importc: "tre_regexec", dynlib: treDll.} -proc regerror*(errcode: cint, preg: var TRegex, errbuf: cstring, - errbuf_size: int): int{.cdecl, importc: "tre_regerror", - dynlib: treDll.} -proc regfree*(preg: var TRegex){.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 TRegex, regex: cstring, len: int, cflags: cint): cint{. - cdecl, importc: "tre_regncomp", dynlib: treDll.} -proc regnexec*(preg: var TRegex, string: cstring, len: int, nmatch: int, - pmatch: ptr TRegmatch, 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 TRegmatch ## 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 TRegex, string: cstring, match: ptr TRegamatch, - params: TRegaparams, eflags: cint): cint{.cdecl, - importc: "tre_regaexec", dynlib: treDll.} -proc reganexec*(preg: var TRegex, 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 TRegex, string: ptr TStrSource, nmatch: int, - pmatch: ptr TRegmatch, 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 TRegex): 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 TRegex): 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 86670b450..000000000 --- a/lib/wrappers/zip/libzip.nim +++ /dev/null @@ -1,249 +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 - TZipSourceCmd* = int32 - - TZipSourceCallback* = proc (state: pointer, data: pointer, length: int, - cmd: TZipSourceCmd): int {.cdecl.} - PZipStat* = ptr TZipStat - TZipStat* = 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 - - TZip = object - TZipSource = object - TZipFile = object - - PZip* = ptr TZip ## represents a zip archive - PZipFile* = ptr TZipFile ## represents a file within an archive - PZipSource* = ptr TZipSource ## represents a source for an archive - - -# 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: TZipSourceCallback, - 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 8bdb47106..000000000 --- a/lib/wrappers/zip/zlib.nim +++ /dev/null @@ -1,310 +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 - TAllocfunc* = proc (p: pointer, items: Uint, size: Uint): pointer{.cdecl.} - TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.} - TInternalState*{.final, pure.} = object - PInternalState* = ptr TInternalState - TZStream*{.final, pure.} = object - nextIn*: Pbytef - availIn*: Uint - totalIn*: Ulong - nextOut*: Pbytef - availOut*: Uint - totalOut*: Ulong - msg*: Pbytef - state*: PInternalState - zalloc*: TAllocfunc - zfree*: TFreeFunc - opaque*: pointer - dataType*: int32 - adler*: Ulong - reserved*: Ulong - - TZStreamRec* = TZStream - PZstream* = ptr TZStream - GzFile* = pointer - -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 TZStream, flush: int32): int32{.cdecl, dynlib: libz, - importc: "deflate".} -proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, - importc: "deflateEnd".} -proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, - importc: "inflate".} -proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, - importc: "inflateEnd".} -proc deflateSetDictionary*(strm: var TZStream, dictionary: Pbytef, - dictLength: Uint): int32{.cdecl, dynlib: libz, - importc: "deflateSetDictionary".} -proc deflateCopy*(dest, source: var TZStream): int32{.cdecl, dynlib: libz, - importc: "deflateCopy".} -proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, - importc: "deflateReset".} -proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{. - cdecl, dynlib: libz, importc: "deflateParams".} -proc inflateSetDictionary*(strm: var TZStream, dictionary: Pbytef, - dictLength: Uint): int32{.cdecl, dynlib: libz, - importc: "inflateSetDictionary".} -proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz, - importc: "inflateSync".} -proc inflateReset*(strm: var TZStream): 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 TZStream, level: int32, version: cstring, - streamSize: int32): int32{.cdecl, dynlib: libz, - importc: "deflateInit_".} -proc inflateInitu*(strm: var TZStream, version: cstring, - streamSize: int32): int32 {. - cdecl, dynlib: libz, importc: "inflateInit_".} -proc deflateInit*(strm: var TZStream, level: int32): int32 -proc inflateInit*(strm: var TZStream): int32 -proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32, - windowBits: int32, memLevel: int32, strategy: int32, - version: cstring, streamSize: int32): int32 {.cdecl, - dynlib: libz, importc: "deflateInit2_".} -proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring, - streamSize: int32): int32{.cdecl, dynlib: libz, - importc: "inflateInit2_".} -proc deflateInit2*(strm: var TZStream, - level, `method`, windowBits, memLevel, - strategy: int32): int32 -proc inflateInit2*(strm: var TZStream, 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 TZStream, level: int32): int32 = - result = deflateInitu(strm, level, zlibVersion(), sizeof(TZStream).cint) - -proc inflateInit(strm: var TZStream): int32 = - result = inflateInitu(strm, zlibVersion(), sizeof(TZStream).cint) - -proc deflateInit2(strm: var TZStream, - level, `method`, windowBits, memLevel, - strategy: int32): int32 = - result = deflateInit2u(strm, level, `method`, windowBits, memLevel, - strategy, zlibVersion(), sizeof(TZStream).cint) - -proc inflateInit2(strm: var TZStream, windowBits: int32): int32 = - result = inflateInit2u(strm, windowBits, zlibVersion(), - sizeof(TZStream).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: TZStream - # 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 73fd53c34..000000000 --- a/lib/wrappers/zip/zzip.nim +++ /dev/null @@ -1,172 +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 -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 - TZZipDir* {.final, pure.} = object - TZZipFile* {.final, pure.} = object - TZZipPluginIO* {.final, pure.} = object - - TZZipDirent* {.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 - - TZZipStat* = TZZipDirent - -proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname, - importc: "zzip_strerror".} -proc zzip_strerror_of*(dir: ptr TZZipDir): 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 TZZipDir): int32 {.cdecl, dynlib: dllname, - importc: "zzip_error".} -proc zzip_seterror*(dir: ptr TZZipDir, 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 TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname, - importc: "zzip_dirhandle".} -proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, - importc: "zzip_dirfd".} -proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, - importc: "zzip_dir_real".} -proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, - importc: "zzip_file_real".} -proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname, - importc: "zzip_realdir".} -proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, - importc: "zzip_realfd".} - -proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl, - dynlib: dllname, importc: "zzip_dir_alloc".} -proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, - importc: "zzip_dir_free".} - -proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl, - dynlib: dllname, importc: "zzip_dir_fdopen".} -proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {. - cdecl, dynlib: dllname, importc: "zzip_dir_open".} -proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, - importc: "zzip_dir_close".} -proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl, - dynlib: dllname, importc: "zzip_dir_read".} - -proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname, - importc: "zzip_opendir".} -proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, - importc: "zzip_closedir".} -proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname, - importc: "zzip_readdir".} -proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, - importc: "zzip_rewinddir".} -proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname, - importc: "zzip_telldir".} -proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname, - importc: "zzip_seekdir".} - -proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {. - cdecl, dynlib: dllname, importc: "zzip_file_open".} -proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, - importc: "zzip_file_close".} -proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. - cdecl, dynlib: dllname, importc: "zzip_file_read".} -proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl, - dynlib: dllname, importc: "zzip_open".} -proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, - importc: "zzip_close".} -proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. - cdecl, dynlib: dllname, importc: "zzip_read".} - -proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {. - cdecl, dynlib: dllname, importc: "zzip_freopen".} -proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl, - dynlib: dllname, importc: "zzip_fopen".} -proc zzip_fread*(p: pointer, size: int, nmemb: int, - file: ptr TZZipFile): int {.cdecl, dynlib: dllname, - importc: "zzip_fread".} -proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, - importc: "zzip_fclose".} - -proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, - importc: "zzip_rewind".} -proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {. - cdecl, dynlib: dllname, importc: "zzip_seek".} -proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname, - importc: "zzip_tell".} - -proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat, - flags: int32): int32 {.cdecl, dynlib: dllname, - importc: "zzip_dir_stat".} -proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, - dynlib: dllname, importc: "zzip_file_stat".} -proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname, - importc: "zzip_fstat".} - -proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring, - o_flags: int32, o_modes: int32, ext: cstringArray, - io: ptr TZZipPluginIO): ptr TZZipFile {.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 TZZipPluginIO): ptr TZZipFile {. - cdecl, dynlib: dllname, importc: "zzip_open_ext_io".} -proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, - ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. - cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".} -proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, - ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. - cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".} |