The stick2xyz Documentation 1.14.1
Creating Stick Figure Viewer/Converter Modules

To create any module, be advised that you can have a structure or class acting as the handle. The program will call your C functions via ltdl, eliminating the need for the program itself (as well as modules that may depend on your module) to access your handles directly.

In the source code of the project, there are a few files that you can use in your own project to dynamically load the modules. In src/stick2xyz, there are three source files that make up the dynamic loader. dymload.h is the header to use with the two other source files, windll.c (for Windows) and dynamic.c (for other OS). If you choose to use dynamic.c, you will need to install <libltdl> from your distro. There is a libltdl in the source tarball of stick2xyz, but it is not as reliable as the libltdl provided by your distro. With either C source code file, you will also need to change the stick2xyz_stick2xyz_*() functions to output of your choice, or comment them out if you do not need error output. Be sure to copy dymload.h, windll.c, and dynamic.c to your project before editing your copies in your project.

Note
All functions listed are required to be supported in the corresponding module type of your module unless noted otherwise.

Module Type Table of Contents

  1. The reuseable code for dynamic loading
  2. The Human Language Pack System and the Modules
  3. Pane 2-D Modules
  4. Output 2-D Modules
  5. Input Modules

The reuseable code for dynamic loading

funcptrs_init - This function initializes the function pointers.

funcptrs_release - This function can deallocate the function pointers.

funcptrs_init_modules - This function increments the reference counts in the modules.

funcptrs_release_modules - This function is for emergency deallocation of the modules.

funcptrs_output2d_getstruct - This function gets function pointers from a Output 2-D module by name.

funcptrs_output2d_enumstruct - This function gets function pointers from a Output 2-D module by number.

funcptrs_pane2d_getstruct - This function gets function pointers from a Pane 2-D module by name.

funcptrs_pane2d_enumstruct - This function gets function pointers from a Pane 2-D module by number.

funcptrs_input_getstruct - This function gets function pointers from an Input module by name.

funcptrs_input_enumstruct - This function gets function pointers from an Input module by number.

The Human Language Pack System and the Modules

Pane 2-D Modules

mod_pane2d_type - Returns a type of STICK2XYZ_MODTYPE_PANE2D_*.

mod_pane2d_name - Returns a UNIX-like name of the module. It is suggested that this name be something acceptable by, for example, SF.net as a UNIX project name.

mod_pane2d_desc - Returns a short description of the module.

mod_pane2d_version - Sets up its version number into an array of three integers.

mod_pane2d_lang - An OPTIONAL function that can be used to receive the function pointer to a language library. This function is not used on Windows builds.

mod_pane2d_set_tty - A function to receive descriptors to stdout and stderr through the application.

mod_pane2d_can_multithread - Returns whether multithreading is supported by the module.

mod_pane2d_is_multithreaded - Returns whether the given handle is multithreaded.

mod_pane2d_get_bpp - Returns the bits per pixel the module stores image data in.

mod_pane2d_getref - Returns the reference count of the given handle.

mod_pane2d_addref - Increments the reference count of the given handle.

mod_pane2d_releaseref - Decrements the reference count of the given handle, and frees the handle when reference count reaches 0.

mod_pane2d_isowner - Allows calling thread to know whether or not it owns a Pane 2-D handle.

mod_pane2d_candraw - Allows calling thread to know whether or not it has drawing rights to a Pane 2-D handle.

mod_pane2d_getownerinfo_windows - A Windows specific function that retrieves the thread id of the owning thread of a handle. This function is OPTIONAL.

mod_pane2d_getdrawaclinfo_windows - A Windows specific function that retrieves the thread ids of the threads allowed to write data to a handle. This function is OPTIONAL.

mod_pane2d_freedrawaclinfo_windows - A Windows specific function that frees data allocated by mod_pane2d_getdrawaclinfo_windows. This function is OPTIONAL.

mod_pane2d_waituntilowner - Allows a non-owning thread of a handle to accept ownership of the handle.

mod_pane2d_termwaituntilowner - Allows an owning thread to cancel the changeover of ownership to another thread.

mod_pane2d_changeaccesscontrol - Allows an owning thread to change permissions other threads have to a handle.

mod_pane2d_changeowningthread - Allows an owning thread to pass ownership of a handle to another thread.

mod_pane2d_eventreleased - Returns a duplicate HANDLE to the event object that is signaled when the Pane 2-D handle is deallocated. This function is only implemented on Windows and Linux.

mod_pane2d_alloc - Asks module to allocate a new pane2d handle.

mod_pane2d_alloc_multithread - Asks module to allocate a new pane2d handle with multithread support.

mod_pane2d_clear - Clears the image data in the pane2d handle.

mod_pane2d_free - Asks module to deallocate a pane2d handle.

mod_pane2d_dupdata - Duplicates a pane2d handle's data. This function has to be implemented, but can return NULL as it is deprecated.

mod_pane2d_dupimage - Duplicates a pane2d handle's image data in a more safe manner.

mod_pane2d_freeimage - Frees duplicated image data that was created with mod_pane2d_dupimage.

mod_pane2d_dupimage16 - Duplicates a pane2d handle's image data in a more safe manner.

mod_pane2d_freeimage16 - Frees duplicated image data that was created with mod_pane2d_dupimage16.

mod_pane2d_dupdatap - Duplicates a pane2d handle's image data into a single dimensional array instead of a two dimensional array.

mod_pane2d_freedatap - Frees data allocated by mod_pane2d_dupdatap

mod_pane2d_dupdata16p - Duplicates a pane2d handle's image data into a single dimensional array instead of a two dimensional array.

mod_pane2d_freedata16p - Frees data allocated by mod_pane2d_dupdata16p

mod_pane2d_dupfunc_getlist - Retrieves a list of function pointers for allocating and freeing image data based on the type of image that is requested.

mod_pane2d_dupxy - Duplicates a pane2d handle's maximum X and Y coordinates.

mod_pane2d_drawpixel - Draws a pixel on the pane2d handle.

mod_pane2d_drawline - Draws a line on the pane2d handle.

mod_pane2d_drawcircle - Draws a circle on the pane2d handle.

mod_pane2d_fillcircle - Draws a circle on the pane2d handle.

mod_pane2d_drawellipse - Draws an ellipse on the pane2d handle.

mod_pane2d_fillellipse - Draws an ellipse on the pane2d handle.

mod_pane2d_drawrect - Draws a rectangle on the pane2d handle.

mod_pane2d_fillrect - Draws a rectangle on the pane2d handle.

mod_pane2d_drawsquare - Draws a square on the pane2d handle.

mod_pane2d_fillsquare - Draws a square on the pane2d handle.

mod_pane2d_drawtriangle - Draws a triangle on the pane2d handle.

mod_pane2d_filltriangle - Draws a triangle on the pane2d handle.

mod_pane2d_drawrighttriangle - Draws a right triangle on the pane2d handle.

mod_pane2d_fillrighttriangle - Draws a right triangle on the pane2d handle.

mod_pane2d_texture_add_gray - Adds an 8-bit gray texture to the pane2d handle.

mod_pane2d_texture_add_gray16 - Adds a 16-bit gray texture to the pane2d handle.

mod_pane2d_texture_add_rgb - Adds an 8-bit RGB texture to the pane2d handle.

mod_pane2d_texture_add_rgb16 - Adds a 16-bit RGB texture to the pane2d handle.

mod_pane2d_texture_clear - Clears the array of textures in a pane2d handle.

mod_pane2d_texture_enum - Retrieves a texture from the pane2d handle.

mod_pane2d_colortype - Gets the color type that is stored by the module.

mod_pane2d_vertex_setopts - Sets vertex options on the pane2d handle.

mod_pane2d_vertex_getopts - Gets vertex options from the pane2d handle.

mod_pane2d_vertex_get - Gets an element in the vertex array from the pane2d handle.

mod_pane2d_vertex_get_v2 - Gets an element in the vertex array from the pane2d handle.

mod_pane2d_print_segment - Prints out some information about the data in the pane2d handle. This function is OPTIONAL, as it's intended for debugging purposes.

mod_pane2d_init - Called when the module is initialized. This function is OPTIONAL.

mod_pane2d_release - Called when the module is being unloaded. This function is OPTIONAL.

mod_pane2d_sigterm - Called when the program catches signal SIGTERM. This function is OPTIONAL and can not be called async safe. This function is not implemented on Windows.

Output 2-D Modules

mod_output2d_type - Returns a type of STICK2XYZ_MODTYPE_OUTPUT2D_*.

mod_output2d_name - Returns a UNIX-like name of the module. It is suggested that this name be something acceptable by, for example, SF.net as a UNIX project name.

mod_output2d_desc - Returns a short description of the module.

mod_output2d_version - Sets up its version number into an array of three integers.

mod_output2d_lang - An OPTIONAL function that can be used to receive the function pointer to a language library. This function is not used on Windows builds.

mod_output2d_set_tty - A function to receive descriptors to stdout and stderr through the application.

mod_output2d_multithread_safe - Allows the module to report whether or not it is safe to use multithreaded.

mod_pane_to_output2d - Converts a 2-D Pane handle into an Output 2-D handle. This function is deprecated and can be programmed to always fail.

mod_paneimage_to_output2d - Converts a 2-D Pane handle into an Output 2-D handle.

mod_pane16bytype_to_output2d - Converts a 2-D Pane handle into an Output 2-D handle based on what the calling Output 2-D handle needs as a source buffer.

mod_panebytype_to_output2d - Converts a 2-D Pane handle into an Output 2-D handle based on what the calling Output 2-D handle needs as a source buffer.

mod_output2d_free_handle - Frees an Output 2-D handle.

mod_output2d_getnewdata - Retrieves new data from the Pane 2-D handle assigned by mod_panebytype_to_output2d.

mod_output2d_quality_range - Allows the Output 2-D module to report various compression value information to the program.

mod_output2d_quality_valid - Allows the Output 2-D module to report whether a given compression value is valid. This function is OPTIONAL.

mod_output2d_bpp_list - Lists in an array the supported bits per pixel values.

mod_output2d_bpp_supported - Returns true if bpp value is supported by the module, false otherwise.

mod_output2d_bpp_default - Returns the default bits per pixel the module support.

mod_output2d_write - Writes out data according to the module's instructions, to a file.

mod_output2d_write_w - Writes out data according to the module's instructions, to a file. This function is implemented only on Windows builds.

mod_output2d_read - Reads data from a file and prints out some of its data to the terminal. This function is OPTIONAL, as it's intended for debugging purposes.

mod_output2d_init - Called when the module is initialized. This function is OPTIONAL.

mod_output2d_release - Called when the module is being unloaded. This function is OPTIONAL.

mod_output2d_sigterm - Called when the program catches signal SIGTERM. This function is OPTIONAL and can not be called async safe. This function is not implemented on Windows.

Input Modules

mod_input_type - Returns a type of STICK2XYZ_MODTYPE_OUTPUT2D_*.

mod_input_name - Returns a UNIX-like name of the module. It is suggested that this name be something acceptable by, for example, SF.net as a UNIX project name.

mod_input_desc - Returns a short description of the module.

mod_input_version - Sets up its version number into an array of three integers.

mod_input_lang - An OPTIONAL function that can be used to receive the function pointer to a language library. This function is not used on Windows builds.

mod_input_set_tty - A function to receive descriptors to stdout and stderr through the application.

mod_input_fwopen - Opens a stream to a particular file via the _wfopen() or fopen() function.

mod_input_fwopen_bt - Opens a stream to a particular file via the _wfopen() or fopen() function. This function is similar to mod_input_fwopen, as an additional parameter is provided for indicating and receiving the file type.

mod_input_fopen - Opens a stream to a particular file via the fopen() function.

mod_input_fopen_bt - Opens a stream to a particular file via the fopen() function. This function is similar to mod_input_fopen, as an additional parameter is provided for indicating and receiving the file type.

mod_input_fdopen - Opens a stream to a specified system descriptor. This is useful when reading from sockets and pipes.

mod_input_fdopen_bt - Opens a stream to a specified system descriptor. This is useful when reading from sockets and pipes. This function is similar to mod_input_fdopen, as an additional parameter is provided for indicating and receiving the file type.

mod_input_open - Opens some form of input based on information contained in the provided string.

mod_input_open_bt - Opens some form of input based on information contained in the provided string. This function is similar to mod_input_open, as an additional parameter is provided for indicating and receiving the file type.

mod_input_close - Closes an open input handle.

mod_input_get_algorithm - Used to get the compression type of the input file.

mod_input_get_utftype - Used to get the UTF encoding type of the input file.

mod_input_get_lineno - Used to get the current line number that the input stream is at.

mod_input_type_supported - Tells the program whether a given compression algorithm is supported by the module.

mod_input_get_supportedalgorithm - Returns bits of STICK2XYZ_INPUT_TYPE_* that is supported by the module.

mod_input_read - Reads the next command from a handle.

mod_input_init - Called when the module is initialized. This function is OPTIONAL.

mod_input_release - Called when the module is being unloaded. This function is OPTIONAL.

mod_input_sigterm - Called when the program catches signal SIGTERM. This function is OPTIONAL and can not be called async safe. This function is not implemented on Windows.

SourceForge.net Logo  stick2xyz Project Page