The stick2xyz Documentation 1.14.1
inputbasic.c File Reference
#include "inputbasicpriv.h"
Include dependency graph for inputbasic.c:

Go to the source code of this file.

Functions

stick2xyz_pctchar mod_input_name (void)
 
stick2xyz_pctchar mod_input_desc (void)
 
void mod_input_version (int *dest)
 
int mod_input_type (void)
 
void mod_input_set_tty (void *fildescout, void *fildescerr)
 
int mod_input_type_supported (uint32_t filtype)
 
uint32_t mod_input_get_supportedalgorithm (void)
 
input_handle mod_input_fopen (const char *filnam)
 
input_handle mod_input_fopen_bt (const char *filnam, uint32_t *filtype)
 
input_handle mod_input_fwopen (const wchar_t *filnam)
 
input_handle mod_input_fwopen_bt (const wchar_t *filnam, uint32_t *filtype)
 
input_handle mod_input_fdopen (int fildes)
 
input_handle mod_input_fdopen_bt (int fildes, uint32_t *filtype)
 
input_handle mod_input_open (void *fildes)
 
input_handle mod_input_open_bt (void *fildes, uint32_t *filtype)
 
void mod_input_close (input_handle handle)
 
uint32_t mod_input_get_algorithm (input_handle handle)
 
uint32_t mod_input_get_utftype (input_handle handle)
 
uint64_t mod_input_get_lineno (input_handle handle)
 
int mod_input_read (input_handle handle, struct input_buf *dest, size_t dest_size, size_t dest_str_size)
 
int mod_input_init (int multithread)
 
int mod_input_release (void)
 
int mod_input_sigterm (input_sigterm_ready func, int modnumber)
 
void mod_input_lang (stick2xyz_print_ptr newval)
 

Function Documentation

◆ mod_input_close()

void mod_input_close ( input_handle  handle)

Closes an input handle.

Parameters
[in]handleThe handle to close.

Definition at line 549 of file inputbasic.c.

References inputbasic_close().

Here is the call graph for this function:

◆ mod_input_desc()

stick2xyz_pctchar mod_input_desc ( void  )

Returns the the internally stored module short description.

Return values
stick2xyz_pctcharThe constant module short description.

Definition at line 255 of file inputbasic.c.

References inputbasic_desc().

Here is the call graph for this function:

◆ mod_input_fdopen()

input_handle mod_input_fdopen ( int  fildes)

Opens a file using fdopen, using a descriptor created by the system. The system descriptor can potentially be a socket, pipe, or file opened with the system open function.

Parameters
[in]fildesThe system descriptor to run through fdopen.
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 455 of file inputbasic.c.

References inputbasic_fdopen().

Here is the call graph for this function:

◆ mod_input_fdopen_bt()

input_handle mod_input_fdopen_bt ( int  fildes,
uint32_t *  filtype 
)

Opens a file using fdopen, using a descriptor created by the system. The system descriptor can potentially be a socket, pipe, or file opened with the system open function.

Parameters
[in]fildesThe system descriptor to run through fdopen.
[in,out]filtypeOne of the following types is input: STICK2XYZ_INPUT_TYPE_AUTO, STICK2XYZ_INPUT_TYPE_PLAIN, STICK2XYZ_INPUT_TYPE_GZIP, STICK2XYZ_INPUT_TYPE_BZIP2, STICK2XYZ_INPUT_TYPE_LZMA2 The value will be changed if STICK2XYZ_INPUT_TYPE_AUTO is passed in. This allows the application to know the detected encoding of the file, even if the function fails. However, the bit-wise value involving UTF encodings will always change by being OR'ed to filtype unless the descriptor could not be opened. STICK2XYZ_INPUT_TYPE_IS_UTF8 macro is provided starting in 1.14.x that can be used to determine if any of the following flags are set. STICK2XYZ_INPUT_TYPE_UTF32BE, STICK2XYZ_INPUT_TYPE_UTF32LE, STICK2XYZ_INPUT_TYPE_UTF16BE, STICK2XYZ_INPUT_TYPE_UTF16LE
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 490 of file inputbasic.c.

References inputbasic_fdopen_bt().

Here is the call graph for this function:

◆ mod_input_fopen()

input_handle mod_input_fopen ( const char *  filnam)

Opens a file using fopen, with a name encoded in ASCII or UTF-8.

Parameters
[in]filnamThe path/file combination to open.
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 347 of file inputbasic.c.

References inputbasic_fopen().

Here is the call graph for this function:

◆ mod_input_fopen_bt()

input_handle mod_input_fopen_bt ( const char *  filnam,
uint32_t *  filtype 
)

Opens a file using fopen, with a name encoded by selected type.

Parameters
[in]filnamThe path/file combination to open.
[in,out]filtypeOne of the following types is input: STICK2XYZ_INPUT_TYPE_AUTO, STICK2XYZ_INPUT_TYPE_PLAIN, STICK2XYZ_INPUT_TYPE_GZIP, STICK2XYZ_INPUT_TYPE_BZIP2, STICK2XYZ_INPUT_TYPE_LZMA2 The value will be changed if STICK2XYZ_INPUT_TYPE_AUTO is passed in. This allows the application to know the detected encoding of the file, even if the function fails. However, the bit-wise value involving UTF encodings will always change by being OR'ed to filtype unless the file could not be opened. STICK2XYZ_INPUT_TYPE_IS_UTF8 macro is provided starting in 1.14.x that can be used to determine if any of the following flags are set. STICK2XYZ_INPUT_TYPE_UTF32BE, STICK2XYZ_INPUT_TYPE_UTF32LE, STICK2XYZ_INPUT_TYPE_UTF16BE, STICK2XYZ_INPUT_TYPE_UTF16LE
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 380 of file inputbasic.c.

References inputbasic_fopen_bt().

Here is the call graph for this function:

◆ mod_input_fwopen()

input_handle mod_input_fwopen ( const wchar_t *  filnam)

Opens a file using any available FileOpen mechanism that can take a wide character input as a file name. If there is no available wide character naming mechanism available in the operating system, the name will be converted to a multi-byte string and fopen'ed.

Parameters
[in]filnamA wide character filename to open.
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 400 of file inputbasic.c.

References inputbasic_fwopen().

Here is the call graph for this function:

◆ mod_input_fwopen_bt()

input_handle mod_input_fwopen_bt ( const wchar_t *  filnam,
uint32_t *  filtype 
)

Opens a file using any available FileOpen mechanism that can take a wide character input as a file name. If there is no available wide character naming mechanism available in the operating system, the name will be converted to a multi-byte string and fopen'ed.

Parameters
[in]filnamA wide character filename to open.
[in,out]filtypeOne of the following types is input: STICK2XYZ_INPUT_TYPE_AUTO, STICK2XYZ_INPUT_TYPE_PLAIN, STICK2XYZ_INPUT_TYPE_GZIP, STICK2XYZ_INPUT_TYPE_BZIP2, STICK2XYZ_INPUT_TYPE_LZMA2 The value will be changed if STICK2XYZ_INPUT_TYPE_AUTO is passed in. This allows the application to know the detected encoding of the file, even if the function fails. However, the bit-wise value involving UTF encodings will always change by being OR'ed to filtype unless the file could not be opened. STICK2XYZ_INPUT_TYPE_IS_UTF8 macro is provided starting in 1.14.x that can be used to determine if any of the following flags are set. STICK2XYZ_INPUT_TYPE_UTF32BE, STICK2XYZ_INPUT_TYPE_UTF32LE, STICK2XYZ_INPUT_TYPE_UTF16BE, STICK2XYZ_INPUT_TYPE_UTF16LE
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 437 of file inputbasic.c.

References inputbasic_fwopen_bt().

Here is the call graph for this function:

◆ mod_input_get_algorithm()

uint32_t mod_input_get_algorithm ( input_handle  handle)

Gets the algorithm used to decompress the input file.

Parameters
[in]handleThe handle to query.
Return values
STICK2XYZ_INPUT_TYPE_GZIPif the file is compressed in gzip.
STICK2XYZ_INPUT_TYPE_BZIP2if the file is compressed in bzip2.
STICK2XYZ_INPUT_TYPE_LZMA2if the file is compressed in xz.
STICK2XYZ_INPUT_TYPE_PLAINif the file is not compressed.
-1If handle is NULL.

Definition at line 569 of file inputbasic.c.

References inputbasic_get_algorithm().

Here is the call graph for this function:

◆ mod_input_get_lineno()

uint64_t mod_input_get_lineno ( input_handle  handle)

Gets the last line number read from the input file.

Parameters
[in]handleThe handle to query.
Return values
>0The last line number read.
0If the file has not been read or is a binary file.

Definition at line 606 of file inputbasic.c.

References inputbasic_get_lineno().

Here is the call graph for this function:

◆ mod_input_get_supportedalgorithm()

uint32_t mod_input_get_supportedalgorithm ( void  )

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

Return values
uint32_tSupported compression algorithms in a bitwise format.

Definition at line 332 of file inputbasic.c.

References inputbasic_get_supportedalgorithm().

Here is the call graph for this function:

◆ mod_input_get_utftype()

uint32_t mod_input_get_utftype ( input_handle  handle)

Gets the UTF byte size and endian of the input file.

Parameters
[in]handleThe handle to query.
Return values
STICK2XYZ_INPUT_TYPE_UTF16BEif the file is encoded in UTF-16 Big Endian.
STICK2XYZ_INPUT_TYPE_UTF16LEif the file is encoded in UTF-16 Little Endian.
STICK2XYZ_INPUT_TYPE_UTF32BEif the file is encoded in UTF-32 Big Endian.
STICK2XYZ_INPUT_TYPE_UTF32LEif the file is encoded in UTF-32 Little Endian.
STICK2XYZ_INPUT_TYPE_UTF8if the file is encoded in UTF-8 or ASCII.
-1If handle is NULL.

Definition at line 591 of file inputbasic.c.

References inputbasic_get_utftype().

Here is the call graph for this function:

◆ mod_input_init()

int mod_input_init ( int  multithread)

This optional function is called when the module is initialized. This function allows you to return a count of references to the module.

Parameters
[in]multithread1 if program is running with multiple threads, 0 if program is running single threaded.
Return values
0on error.
1any positive integer means success.

Definition at line 660 of file inputbasic.c.

◆ mod_input_lang()

void mod_input_lang ( stick2xyz_print_ptr  newval)

Changes the pointer type of the language pack calling function.

Parameters
[in]newvalThe new function pointer to store.

Definition at line 721 of file inputbasic.c.

References inputbasic_lang().

Here is the call graph for this function:

◆ mod_input_name()

stick2xyz_pctchar mod_input_name ( void  )

Returns the internally stored UNIX module name.

Return values
stick2xyz_pctcharThe constant UNIX module name.

Definition at line 245 of file inputbasic.c.

References inputbasic_name().

Here is the call graph for this function:

◆ mod_input_open()

input_handle mod_input_open ( void *  fildes)

Opens a file using an already fopen'ed FILE descriptor.

Parameters
[in]fildesThe FILE descriptor to utilize.
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 505 of file inputbasic.c.

References inputbasic_open().

Here is the call graph for this function:

◆ mod_input_open_bt()

input_handle mod_input_open_bt ( void *  fildes,
uint32_t *  filtype 
)

Opens a file using an already fopen'ed FILE descriptor.

Parameters
[in]fildesThe FILE descriptor to utilize.
[in,out]filtypeOne of the following types is input: STICK2XYZ_INPUT_TYPE_AUTO, STICK2XYZ_INPUT_TYPE_PLAIN, STICK2XYZ_INPUT_TYPE_GZIP, STICK2XYZ_INPUT_TYPE_BZIP2, STICK2XYZ_INPUT_TYPE_LZMA2 The value will be changed if STICK2XYZ_INPUT_TYPE_AUTO is passed in. This allows the application to know the detected encoding of the file, even if the function fails. However, the bit-wise value involving UTF encodings will always change by being OR'ed to filtype unless the descriptor could not be opened. STICK2XYZ_INPUT_TYPE_IS_UTF8 macro is provided starting in 1.14.x that can be used to determine if any of the following flags are set. STICK2XYZ_INPUT_TYPE_UTF32BE, STICK2XYZ_INPUT_TYPE_UTF32LE, STICK2XYZ_INPUT_TYPE_UTF16BE, STICK2XYZ_INPUT_TYPE_UTF16LE
Return values
input_handleA handle to pass in to the read functions.
NULLIf an error occured.

Definition at line 538 of file inputbasic.c.

References inputbasic_open_bt().

Here is the call graph for this function:

◆ mod_input_read()

int mod_input_read ( input_handle  handle,
struct input_buf dest,
size_t  dest_size,
size_t  dest_str_size 
)

Reads in the next line from the file. The destination array will be formatted as follows:

dest[0] = uint32_t type
dest[1] = char[dest_str_size] deststr
dest[2+] = int destints
Note
This function may change the value of errno to zero. This is necessary since it is possible that strtoul may be called to interpret a number in a string.
Parameters
[in]handleThe handle whose data is to be read.
[out]destAn array as described above.
[in]dest_sizeThe amount of elements in the array.
[in]dest_str_sizeThe amount of characters in the dest string.
Return values
>0Amount of characters read.
0EOF reached.
-1An I/O error occured.

Definition at line 635 of file inputbasic.c.

References inputbasic_read().

Here is the call graph for this function:

◆ mod_input_release()

int mod_input_release ( void  )

This optional function is called when the module is being unloaded. This function allows you to run any cleanup code independent of the operating system's way of notifying the module.

Return values
0when module is ready to be unloaded.
1any positive integer means module is not ready to be unloaded.

Definition at line 675 of file inputbasic.c.

◆ mod_input_set_tty()

void mod_input_set_tty ( void *  fildescout,
void *  fildescerr 
)

This function sets the file descriptors for writing to the terminal.

By default, the library uses stdout and stderr.

This function was introduced in version 1.5.0.

Parameters
[in]fildescoutThe file descriptor for stdout.
[in]fildescerrThe file descriptor for stderr.

Definition at line 304 of file inputbasic.c.

References inputbasic_set_tty().

Here is the call graph for this function:

◆ mod_input_sigterm()

int mod_input_sigterm ( input_sigterm_ready  func,
int  modnumber 
)

This optional function is called when the program receives signal SIGTERM.

Note
One use of this function is to let all output to a file, pipe, or socket finish before letting the program terminate itself.
Warning
This function will be called inside a signal handler. Also, do not attempt to directly catch SIGTERM in a module. This function is the way for a module to catch SIGTERM. The code needs to be written as light as possible. Remember that the signal handler will freeze the entire program and the modules until the handler returns. This function is not implemented on Windows because TerminateProcess() is equivalent to SIGKILL. There is no equivalent SIGTERM on Windows, even though the C runtime defines SIGTERM.
Parameters
[in]funcThe function for the module to call when ready for program exit, if 0 is returned by the module.
[in]modnumberThe module number in the dynamic or static array. This number is the parameter when calling func.
Return values
1module is ready to be unloaded.
0module is not ready to be unloaded.

Definition at line 707 of file inputbasic.c.

◆ mod_input_type()

int mod_input_type ( void  )

Returns the integer describing the module type.

The possible values are:

ASCII Modules:

STICK2XYZ_MODTYPE_PANE2D

STICK2XYZ_MODTYPE_PANE2D_DEBUG

UNICODE Modules:

STICK2XYZ_MODTYPE_PANE2D_UNICODE

STICK2XYZ_MODTYPE_PANE2D_UNICODE_DEBUG

Return values
intThe module type as described above.

Definition at line 289 of file inputbasic.c.

References inputbasic_type().

Here is the call graph for this function:

◆ mod_input_type_supported()

int mod_input_type_supported ( uint32_t  filtype)

Tells the caller if a file compression type is supported by the module.

Parameters
[in]filtypeA STICK2XYZ_INPUT_TYPE_* to check.
Return values
1If filtype is supported by the module.
0If filtype is not supported by the module.

Definition at line 320 of file inputbasic.c.

References inputbasic_type_supported().

Here is the call graph for this function:

◆ mod_input_version()

void mod_input_version ( int *  dest)

Sets up the major, minor, and revision numbers into three integers.

Parameters
[out]destAn array of three integers to receive the module data.

Definition at line 265 of file inputbasic.c.

References inputbasic_version().

Here is the call graph for this function:

SourceForge.net Logo  stick2xyz Project Page