The stick2xyz Documentation 1.14.1
inputbasic.c
Go to the documentation of this file.
1/***************************************************************************
2 * stick2xyz - Can create and convert stick figure animations for CG. *
3 * Copyright (C) 2021 by Kevin McBride <dolphindddd@aol.com> *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18
19
20#include "inputbasicpriv.h"
21
22
23#ifndef DOXYGEN_BUILD
24
25/* Used for versioning. */
26static int modversion[] =
27 {STICK2XYZ_VER_MAJOR, STICK2XYZ_VER_MINOR, STICK2XYZ_VER_REVISION};
28/* The file descriptors we are outputting tty information to. */
29static FILE * modttyout = NULL;
30static FILE * modttyerr = NULL;
31
32#ifndef STICK2XYZ_NO_MODLANGPACKS
33/* Used for dynamically accessing the language libraries. */
34stick2xyz_print_ptr stick2xyz_lang_lib_inputbasic = NULL;
35
36void inputbasic_lang ( stick2xyz_print_ptr newval )
37{
38 stick2xyz_lang_lib_inputbasic = newval;
39}
40#endif /* not STICK2XYZ_NO_MODLANGPACKS */
41
42
43/* Input General Module Info Functions */
45{
46 return stick2xyz_inputbasic_modname();
47}
48
50{
51 return stick2xyz_inputbasic_moddesc();
52}
53
54void inputbasic_version ( int * dest )
55{
56 dest[0] = modversion[0];
57 dest[1] = modversion[1];
58 dest[2] = modversion[2];
59}
60
61int inputbasic_type ( void )
62{
63#ifdef UNICODE
64#ifdef DEBUG
66#else /* not DEBUG */
68#endif /* not DEBUG */
69#else /* not UNICODE */
70#ifdef DEBUG
72#else /* not DEBUG */
74#endif /* not DEBUG */
75#endif /* not UNICODE */
76}
77
78
79void inputbasic_set_tty ( void * fildescout, void * fildescerr )
80{
81 modttyout = (FILE *)fildescout;
82 modttyerr = (FILE *)fildescerr;
83}
84
85FILE * input_basic_get_ttyout ( void )
86{
87 if ( modttyout == NULL )
88 return stdout;
89 else
90 return modttyout;
91}
92
93FILE * input_basic_get_ttyerr ( void )
94{
95 if ( modttyerr == NULL )
96 return stderr;
97 else
98 return modttyerr;
99}
100
101
102int inputbasic_type_supported ( uint32_t filtype )
103{
104
105 if ( filtype == STICK2XYZ_INPUT_TYPE_AUTO )
106 return 1;
107 if ( filtype & STICK2XYZ_INPUT_TYPE_PLAIN )
108 return 1;
109 if ( filtype & STICK2XYZ_INPUT_TYPE_GZIP )
110#ifdef HAVE_ZLIB_H
111 return 1;
112#else /* not HAVE_ZLIB_H */
113 return 0;
114#endif /* not HAVE_ZLIB_H */
115 if ( filtype & STICK2XYZ_INPUT_TYPE_BZIP2 )
116#ifdef HAVE_BZLIB_H
117 return 1;
118#else /* not HAVE_BZLIB_H */
119 return 0;
120#endif /* not HAVE_BZLIB_H */
121 if ( filtype & STICK2XYZ_INPUT_TYPE_LZMA2 )
122#ifdef HAVE_LZMA_H
123 return 1;
124#else /* not HAVE_LZMA_H */
125 return 0;
126#endif /* not HAVE_LZMA_H */
127
128 return 0;
129}
130
131
132uint32_t inputbasic_get_supportedalgorithm ( void )
133{
134 uint32_t retval;
135
137#ifdef HAVE_ZLIB_H
139#endif /* HAVE_ZLIB_H */
140#ifdef HAVE_BZLIB_H
142#endif /* HAVE_BZLIB_H */
143#ifdef HAVE_LZMA_H
145#endif /* HAVE_LZMA_H */
146
147#ifdef UNICODE
152#endif /* UNICODE */
153
154 return retval;
155}
156
157
158uint32_t inputbasic_get_algorithm ( input_handle handle )
159{
160 struct input_basic_handle * handle_priv;
161
162 /* If handle is NULL, we can't do anything. */
163 if ( handle == NULL )
164 return -1;
165
166 /* Cast the handle. */
167 handle_priv = (struct input_basic_handle *)handle;
168
169#ifdef HAVE_ZLIB_H
170 /* Determine if the type is gzip. */
171 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_GZIP )
173#endif /* HAVE_ZLIB_H */
174
175#ifdef HAVE_BZLIB_H
176 /* Determine if the type is bzip2. */
177 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_BZIP2 )
179#endif /* HAVE_BZLIB_H */
180
181#ifdef HAVE_LZMA_H
182 /* Determine if the type is LZMA2. */
183 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_LZMA2 )
185#endif /* HAVE_LZMA_H */
186
187 /* The type is plain. */
189}
190
191uint32_t inputbasic_get_utftype ( input_handle handle )
192{
193 /* If handle is NULL, we can't do anything. */
194 if ( handle == NULL )
195 return -1;
196
197#ifdef UNICODE
198 struct input_basic_handle * handle_priv;
199
200 /* Cast the handle. */
201 handle_priv = (struct input_basic_handle *)handle;
202
203 /* Determine if the type is UTF-16 Big Endian. */
204 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_UTF16_BIG )
206 /* Determine if the type is UTF-16 Little Endian. */
207 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_UTF16_LITTLE )
209 /* Determine if the type is UTF-16 Big Endian. */
210 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_UTF32_BIG )
212 /* Determine if the type is UTF-16 Little Endian. */
213 if ( handle_priv->input_basic_handle_flags & INPUTBASIC_UTF32_LITTLE )
215#endif /* not UNICODE */
216
217 /* The type is UTF-8. */
219}
220
221uint64_t inputbasic_get_lineno ( input_handle handle )
222{
223 struct input_basic_handle * handle_priv;
224
225 /* If handle is NULL, we can't do anything. */
226 if ( handle == NULL )
227 return 0;
228
229 /* Cast the handle. */
230 handle_priv = (struct input_basic_handle *)handle;
231
232 /* Return the line number to the caller. */
233 return handle_priv->input_basic_handle_lineno;
234}
235#endif /* not DOXYGEN_BUILD */
236
237
238#ifndef STICK2XYZ_STATIC
239/* Input Basic Module Info Functions */
246{
248}
249
256{
258}
259
265void mod_input_version ( int * dest )
266{
267 inputbasic_version(dest);
268}
269
289int mod_input_type ( void )
290{
291 return inputbasic_type();
292}
293
304void mod_input_set_tty ( void * fildescout, void * fildescerr )
305{
306 inputbasic_set_tty(fildescout, fildescerr);
307}
308
309
320int mod_input_type_supported ( uint32_t filtype )
321{
322 return inputbasic_type_supported(filtype);
323}
324
325
333{
335}
336
337
347input_handle mod_input_fopen ( const char * filnam )
348{
349 return inputbasic_fopen(filnam);
350}
351
352
380input_handle mod_input_fopen_bt ( const char * filnam, uint32_t * filtype )
381{
382 return inputbasic_fopen_bt(filnam, filtype);
383}
384
385
386#ifdef UNICODE
400input_handle mod_input_fwopen ( const wchar_t * filnam )
401{
402 return inputbasic_fwopen(filnam);
403}
404
405
437input_handle mod_input_fwopen_bt ( const wchar_t * filnam, uint32_t * filtype )
438{
439 return inputbasic_fwopen_bt(filnam, filtype);
440}
441#endif /* UNICODE */
442
443
456{
457 return inputbasic_fdopen(fildes);
458}
459
460
490input_handle mod_input_fdopen_bt ( int fildes, uint32_t * filtype )
491{
492 return inputbasic_fdopen_bt(fildes, filtype);
493}
494
495
506{
507 return inputbasic_open(fildes);
508}
509
510
538input_handle mod_input_open_bt ( void * fildes, uint32_t * filtype )
539{
540 return inputbasic_open_bt(fildes, filtype);
541}
542
543
550{
551 inputbasic_close(handle);
552}
553
554
570{
571 return inputbasic_get_algorithm(handle);
572}
573
592{
593 return inputbasic_get_utftype(handle);
594}
595
607{
608 return inputbasic_get_lineno(handle);
609}
610
636 input_handle handle,
637 struct input_buf * dest,
638 size_t dest_size,
639 size_t dest_str_size
640)
641{
642 return inputbasic_read(
643 handle, dest, dest_size, dest_str_size);
644}
645
646
647#ifdef DOXYGEN_BUILD
660int mod_input_init ( int multithread )
661{
662 return 1;
663}
664
676{
677 return 0;
678}
679
707int mod_input_sigterm ( input_sigterm_ready func, int modnumber )
708{
709 return 1;
710}
711#endif /* DOXYGEN_BUILD */
712
713
714
715#ifndef STICK2XYZ_NO_MODLANGPACKS
721void mod_input_lang ( stick2xyz_print_ptr newval )
722{
723 inputbasic_lang(newval);
724}
725#endif /* not STICK2XYZ_NO_MODLANGPACKS */
726
727
728#else /* STICK2XYZ_STATIC */
729void inputbasic_funcptrs_setup ( struct input_funcptrs * ptr )
730{
736
737 ptr->input_funcptrs_init = NULL;
738 ptr->input_funcptrs_release = NULL;
739 ptr->input_funcptrs_sigterm = NULL;
740
744
751#ifdef UNICODE
754#endif /* UNICODE */
756
763
765}
766#endif /* STICK2XYZ_STATIC */
767
768
void mod_input_version(int *dest)
Definition: inputbasic.c:265
input_handle mod_input_fopen_bt(const char *filnam, uint32_t *filtype)
Definition: inputbasic.c:380
stick2xyz_pctchar mod_input_name(void)
Definition: inputbasic.c:245
uint64_t mod_input_get_lineno(input_handle handle)
Definition: inputbasic.c:606
input_handle mod_input_fdopen(int fildes)
Definition: inputbasic.c:455
void mod_input_close(input_handle handle)
Definition: inputbasic.c:549
uint32_t mod_input_get_algorithm(input_handle handle)
Definition: inputbasic.c:569
input_handle mod_input_fdopen_bt(int fildes, uint32_t *filtype)
Definition: inputbasic.c:490
int mod_input_type_supported(uint32_t filtype)
Definition: inputbasic.c:320
int mod_input_init(int multithread)
Definition: inputbasic.c:660
input_handle mod_input_fwopen_bt(const wchar_t *filnam, uint32_t *filtype)
Definition: inputbasic.c:437
void mod_input_set_tty(void *fildescout, void *fildescerr)
Definition: inputbasic.c:304
input_handle mod_input_fwopen(const wchar_t *filnam)
Definition: inputbasic.c:400
input_handle mod_input_fopen(const char *filnam)
Definition: inputbasic.c:347
uint32_t mod_input_get_utftype(input_handle handle)
Definition: inputbasic.c:591
uint32_t mod_input_get_supportedalgorithm(void)
Definition: inputbasic.c:332
input_handle mod_input_open_bt(void *fildes, uint32_t *filtype)
Definition: inputbasic.c:538
void mod_input_lang(stick2xyz_print_ptr newval)
Definition: inputbasic.c:721
stick2xyz_pctchar mod_input_desc(void)
Definition: inputbasic.c:255
int mod_input_sigterm(input_sigterm_ready func, int modnumber)
Definition: inputbasic.c:707
int mod_input_read(input_handle handle, struct input_buf *dest, size_t dest_size, size_t dest_str_size)
Definition: inputbasic.c:635
input_handle mod_input_open(void *fildes)
Definition: inputbasic.c:505
int mod_input_type(void)
Definition: inputbasic.c:289
int mod_input_release(void)
Definition: inputbasic.c:675
input_handle inputbasic_fdopen_bt(int fildes, uint32_t *filtype)
void inputbasic_close(input_handle handle)
uint32_t inputbasic_get_algorithm(input_handle handle)
int inputbasic_read(input_handle handle, struct input_buf *dest, size_t dest_size, size_t dest_str_size)
int inputbasic_type_supported(uint32_t filtype)
input_handle inputbasic_open(void *fildes)
void inputbasic_version(int *dest)
stick2xyz_pctchar inputbasic_name(void)
void inputbasic_set_tty(void *fildescout, void *fildescerr)
input_handle inputbasic_open_bt(void *fildes, uint32_t *filtype)
uint32_t inputbasic_get_utftype(input_handle handle)
uint64_t inputbasic_get_lineno(input_handle handle)
input_handle inputbasic_fwopen(const wchar_t *filnam)
input_handle inputbasic_fdopen(int fildes)
input_handle inputbasic_fwopen_bt(const wchar_t *filnam, uint32_t *filtype)
uint32_t inputbasic_get_supportedalgorithm(void)
void inputbasic_lang(stick2xyz_print_ptr newval)
input_handle inputbasic_fopen_bt(const char *filnam, uint32_t *filtype)
int inputbasic_type(void)
input_handle inputbasic_fopen(const char *filnam)
stick2xyz_pctchar inputbasic_desc(void)
#define STICK2XYZ_INPUT_TYPE_UTF32BE
Definition: stick2xyz.h:2013
#define STICK2XYZ_INPUT_TYPE_AUTO
Definition: stick2xyz.h:1927
#define STICK2XYZ_MODTYPE_INPUT
Definition: stick2xyz.h:231
#define STICK2XYZ_INPUT_TYPE_UTF16LE
Definition: stick2xyz.h:2003
#define STICK2XYZ_INPUT_TYPE_UTF32LE
Definition: stick2xyz.h:2023
void * input_handle
Definition: stick2xyz.h:1892
#define STICK2XYZ_INPUT_TYPE_GZIP
Definition: stick2xyz.h:1953
#define STICK2XYZ_INPUT_TYPE_UTF8
Definition: stick2xyz.h:1983
const wchar_t * stick2xyz_pctchar
Definition: stick2xyz.h:145
void(* input_sigterm_ready)(int)
Definition: stick2xyz.h:2125
#define STICK2XYZ_MODTYPE_INPUT_UNICODE
Definition: stick2xyz.h:233
#define STICK2XYZ_INPUT_TYPE_BZIP2
Definition: stick2xyz.h:1958
#define STICK2XYZ_INPUT_TYPE_UTF16BE
Definition: stick2xyz.h:1993
#define STICK2XYZ_INPUT_TYPE_PLAIN
Definition: stick2xyz.h:1941
#define STICK2XYZ_MODTYPE_INPUT_UNICODE_DEBUG
Definition: stick2xyz.h:234
#define STICK2XYZ_MODTYPE_INPUT_DEBUG
Definition: stick2xyz.h:232
#define STICK2XYZ_INPUT_TYPE_LZMA2
Definition: stick2xyz.h:1969
input_open_bt input_funcptrs_open_bt
Definition: stick2xyz.h:2218
input_fwopen input_funcptrs_fwopen
Definition: stick2xyz.h:2233
input_fwopen_bt input_funcptrs_fwopen_bt
Definition: stick2xyz.h:2234
input_read input_funcptrs_read
Definition: stick2xyz.h:2230
input_close input_funcptrs_close
Definition: stick2xyz.h:2223
input_type_supported input_funcptrs_type_supported
Definition: stick2xyz.h:2209
input_set_tty input_funcptrs_set_tty
Definition: stick2xyz.h:2207
input_get_algorithm input_funcptrs_get_algorithm
Definition: stick2xyz.h:2225
input_sigterm input_funcptrs_sigterm
Definition: stick2xyz.h:2214
input_get_utftype input_funcptrs_get_utftype
Definition: stick2xyz.h:2226
input_modid_desc input_funcptrs_desc
Definition: stick2xyz.h:2203
input_fdopen_bt input_funcptrs_fdopen_bt
Definition: stick2xyz.h:2222
input_modid_version input_funcptrs_version
Definition: stick2xyz.h:2204
input_get_supportedalgorithm input_funcptrs_get_supportedalgorithm
Definition: stick2xyz.h:2227
input_fopen_bt input_funcptrs_fopen_bt
Definition: stick2xyz.h:2220
input_modid_name input_funcptrs_name
Definition: stick2xyz.h:2202
input_release input_funcptrs_release
Definition: stick2xyz.h:2212
input_fopen input_funcptrs_fopen
Definition: stick2xyz.h:2219
input_fdopen input_funcptrs_fdopen
Definition: stick2xyz.h:2221
input_open input_funcptrs_open
Definition: stick2xyz.h:2217
input_get_lineno input_funcptrs_get_lineno
Definition: stick2xyz.h:2228
input_init input_funcptrs_init
Definition: stick2xyz.h:2211
input_modid_type input_funcptrs_type
Definition: stick2xyz.h:2205

SourceForge.net Logo  stick2xyz Project Page