File indexing completed on 2025-01-17 09:56:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef _TEXTSTYLE_H
0020 #define _TEXTSTYLE_H
0021
0022 #include <stdarg.h>
0023 #include <stddef.h>
0024 #include <stdio.h>
0025 #include <textstyle/stdbool.h>
0026 #include <textstyle/woe32dll.h>
0027
0028
0029 #include <textstyle/version.h>
0030
0031
0032
0033
0034 typedef enum
0035 {
0036
0037
0038 FLUSH_THIS_STREAM = 0,
0039
0040
0041
0042 FLUSH_THIS_PROCESS = 1,
0043
0044
0045
0046
0047 FLUSH_ALL = 2
0048 } ostream_flush_scope_t;
0049
0050
0051
0052
0053 struct any_ostream_representation;
0054 typedef struct any_ostream_representation * ostream_t;
0055
0056
0057 #ifdef __cplusplus
0058 extern "C" {
0059 #endif
0060 extern void ostream_write_mem (ostream_t first_arg, const void *data, size_t len);
0061 extern void ostream_flush (ostream_t first_arg, ostream_flush_scope_t scope);
0062 extern void ostream_free (ostream_t first_arg);
0063 #ifdef __cplusplus
0064 }
0065 #endif
0066
0067 #ifdef __cplusplus
0068 extern "C" {
0069 #endif
0070
0071
0072 extern void ostream_write_str (ostream_t stream, const char *string);
0073
0074
0075
0076
0077 extern ptrdiff_t ostream_printf (ostream_t stream, const char *format, ...)
0078 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
0079 __attribute__ ((__format__ (__printf__, 2, 3)))
0080 #endif
0081 ;
0082 extern ptrdiff_t ostream_vprintf (ostream_t stream,
0083 const char *format, va_list args)
0084 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3
0085 __attribute__ ((__format__ (__printf__, 2, 0)))
0086 #endif
0087 ;
0088
0089 #ifdef __cplusplus
0090 }
0091 #endif
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 typedef ostream_t styled_ostream_t;
0102
0103
0104 #ifdef __cplusplus
0105 extern "C" {
0106 #endif
0107 extern void styled_ostream_write_mem (styled_ostream_t first_arg, const void *data, size_t len);
0108 extern void styled_ostream_flush (styled_ostream_t first_arg, ostream_flush_scope_t scope);
0109 extern void styled_ostream_free (styled_ostream_t first_arg);
0110 extern void styled_ostream_begin_use_class (styled_ostream_t first_arg, const char *classname);
0111 extern void styled_ostream_end_use_class (styled_ostream_t first_arg, const char *classname);
0112 extern const char *styled_ostream_get_hyperlink_ref (styled_ostream_t first_arg);
0113 extern const char *styled_ostream_get_hyperlink_id (styled_ostream_t first_arg);
0114 extern void styled_ostream_set_hyperlink (styled_ostream_t first_arg, const char *ref, const char *id);
0115
0116
0117
0118
0119
0120
0121 extern void styled_ostream_flush_to_current_style (styled_ostream_t stream);
0122 #ifdef __cplusplus
0123 }
0124 #endif
0125
0126 #ifdef __cplusplus
0127 extern "C" {
0128 #endif
0129
0130
0131
0132 extern bool is_instance_of_styled_ostream (ostream_t stream);
0133
0134
0135 #ifdef __cplusplus
0136 }
0137 #endif
0138
0139
0140
0141
0142 typedef ostream_t file_ostream_t;
0143
0144
0145 #ifdef __cplusplus
0146 extern "C" {
0147 #endif
0148 extern void file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len);
0149 extern void file_ostream_flush (file_ostream_t first_arg, ostream_flush_scope_t scope);
0150 extern void file_ostream_free (file_ostream_t first_arg);
0151
0152 extern FILE *file_ostream_get_stdio_stream (file_ostream_t stream);
0153 #ifdef __cplusplus
0154 }
0155 #endif
0156
0157 #ifdef __cplusplus
0158 extern "C" {
0159 #endif
0160
0161
0162
0163
0164 extern file_ostream_t file_ostream_create (FILE *fp);
0165
0166
0167
0168 extern bool is_instance_of_file_ostream (ostream_t stream);
0169
0170
0171 #ifdef __cplusplus
0172 }
0173 #endif
0174
0175
0176
0177
0178 typedef ostream_t fd_ostream_t;
0179
0180
0181 #ifdef __cplusplus
0182 extern "C" {
0183 #endif
0184 extern void fd_ostream_write_mem (fd_ostream_t first_arg, const void *data, size_t len);
0185 extern void fd_ostream_flush (fd_ostream_t first_arg, ostream_flush_scope_t scope);
0186 extern void fd_ostream_free (fd_ostream_t first_arg);
0187
0188 extern int fd_ostream_get_descriptor (fd_ostream_t stream);
0189 extern const char *fd_ostream_get_filename (fd_ostream_t stream);
0190 extern bool fd_ostream_is_buffered (fd_ostream_t stream);
0191 #ifdef __cplusplus
0192 }
0193 #endif
0194
0195 #ifdef __cplusplus
0196 extern "C" {
0197 #endif
0198
0199
0200
0201
0202
0203 extern fd_ostream_t fd_ostream_create (int fd, const char *filename,
0204 bool buffered);
0205
0206
0207
0208 extern bool is_instance_of_fd_ostream (ostream_t stream);
0209
0210
0211 #ifdef __cplusplus
0212 }
0213 #endif
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226 typedef int term_color_t;
0227
0228 enum
0229 {
0230 COLOR_DEFAULT = -1
0231 };
0232
0233 typedef enum
0234 {
0235 WEIGHT_NORMAL = 0,
0236 WEIGHT_BOLD,
0237 WEIGHT_DEFAULT = WEIGHT_NORMAL
0238 } term_weight_t;
0239
0240 typedef enum
0241 {
0242 POSTURE_NORMAL = 0,
0243 POSTURE_ITALIC,
0244 POSTURE_DEFAULT = POSTURE_NORMAL
0245 } term_posture_t;
0246
0247 typedef enum
0248 {
0249 UNDERLINE_OFF = 0,
0250 UNDERLINE_ON,
0251 UNDERLINE_DEFAULT = UNDERLINE_OFF
0252 } term_underline_t;
0253
0254
0255
0256
0257
0258 typedef enum
0259 {
0260 TTYCTL_AUTO = 0,
0261 TTYCTL_NONE,
0262
0263
0264 TTYCTL_PARTIAL,
0265
0266
0267
0268 TTYCTL_FULL
0269
0270
0271
0272 } ttyctl_t;
0273
0274
0275 typedef ostream_t term_ostream_t;
0276
0277
0278 #ifdef __cplusplus
0279 extern "C" {
0280 #endif
0281 extern void term_ostream_write_mem (term_ostream_t first_arg, const void *data, size_t len);
0282 extern void term_ostream_flush (term_ostream_t first_arg, ostream_flush_scope_t scope);
0283 extern void term_ostream_free (term_ostream_t first_arg);
0284 extern term_color_t term_ostream_rgb_to_color (term_ostream_t first_arg, int red, int green, int blue);
0285 extern term_color_t term_ostream_get_color (term_ostream_t first_arg);
0286 extern void term_ostream_set_color (term_ostream_t first_arg, term_color_t color);
0287 extern term_color_t term_ostream_get_bgcolor (term_ostream_t first_arg);
0288 extern void term_ostream_set_bgcolor (term_ostream_t first_arg, term_color_t color);
0289 extern term_weight_t term_ostream_get_weight (term_ostream_t first_arg);
0290 extern void term_ostream_set_weight (term_ostream_t first_arg, term_weight_t weight);
0291 extern term_posture_t term_ostream_get_posture (term_ostream_t first_arg);
0292 extern void term_ostream_set_posture (term_ostream_t first_arg, term_posture_t posture);
0293 extern term_underline_t term_ostream_get_underline (term_ostream_t first_arg);
0294 extern void term_ostream_set_underline (term_ostream_t first_arg, term_underline_t underline);
0295 extern const char *term_ostream_get_hyperlink_ref (term_ostream_t first_arg);
0296 extern const char *term_ostream_get_hyperlink_id (term_ostream_t first_arg);
0297 extern void term_ostream_set_hyperlink (term_ostream_t first_arg, const char *ref, const char *id);
0298
0299
0300
0301
0302
0303
0304
0305 extern void term_ostream_flush_to_current_style (term_ostream_t first_arg);
0306
0307 extern int term_ostream_get_descriptor (term_ostream_t stream);
0308 extern const char *term_ostream_get_filename (term_ostream_t stream);
0309 extern ttyctl_t term_ostream_get_tty_control (term_ostream_t stream);
0310 extern ttyctl_t term_ostream_get_effective_tty_control (term_ostream_t stream);
0311 #ifdef __cplusplus
0312 }
0313 #endif
0314
0315 #ifdef __cplusplus
0316 extern "C" {
0317 #endif
0318
0319
0320
0321
0322
0323
0324
0325 extern term_ostream_t
0326 term_ostream_create (int fd, const char *filename, ttyctl_t tty_control);
0327
0328
0329
0330 extern bool is_instance_of_term_ostream (ostream_t stream);
0331
0332
0333 #ifdef __cplusplus
0334 }
0335 #endif
0336
0337
0338
0339
0340 typedef ostream_t memory_ostream_t;
0341
0342
0343 #ifdef __cplusplus
0344 extern "C" {
0345 #endif
0346 extern void memory_ostream_write_mem (memory_ostream_t first_arg, const void *data, size_t len);
0347 extern void memory_ostream_flush (memory_ostream_t first_arg, ostream_flush_scope_t scope);
0348 extern void memory_ostream_free (memory_ostream_t first_arg);
0349 extern void memory_ostream_contents (memory_ostream_t first_arg, const void **bufp, size_t *buflenp);
0350 #ifdef __cplusplus
0351 }
0352 #endif
0353
0354 #ifdef __cplusplus
0355 extern "C" {
0356 #endif
0357
0358
0359
0360 extern memory_ostream_t memory_ostream_create (void);
0361
0362
0363
0364 extern bool is_instance_of_memory_ostream (ostream_t stream);
0365
0366
0367 #ifdef __cplusplus
0368 }
0369 #endif
0370
0371
0372
0373 #if LIBTEXTSTYLE_USES_ICONV
0374
0375
0376 typedef ostream_t iconv_ostream_t;
0377
0378
0379 #ifdef __cplusplus
0380 extern "C" {
0381 #endif
0382 extern void iconv_ostream_write_mem (iconv_ostream_t first_arg, const void *data, size_t len);
0383 extern void iconv_ostream_flush (iconv_ostream_t first_arg, ostream_flush_scope_t scope);
0384 extern void iconv_ostream_free (iconv_ostream_t first_arg);
0385
0386 extern const char *iconv_ostream_get_from_encoding (iconv_ostream_t stream);
0387 extern const char *iconv_ostream_get_to_encoding (iconv_ostream_t stream);
0388 extern ostream_t iconv_ostream_get_destination (iconv_ostream_t stream);
0389 #ifdef __cplusplus
0390 }
0391 #endif
0392
0393 #ifdef __cplusplus
0394 extern "C" {
0395 #endif
0396
0397
0398
0399
0400 extern iconv_ostream_t iconv_ostream_create (const char *from_encoding,
0401 const char *to_encoding,
0402 ostream_t destination);
0403
0404
0405
0406 extern bool is_instance_of_iconv_ostream (ostream_t stream);
0407
0408
0409 #ifdef __cplusplus
0410 }
0411 #endif
0412
0413 #endif
0414
0415
0416
0417
0418 typedef ostream_t html_ostream_t;
0419
0420
0421 #ifdef __cplusplus
0422 extern "C" {
0423 #endif
0424 extern void html_ostream_write_mem (html_ostream_t first_arg, const void *data, size_t len);
0425 extern void html_ostream_flush (html_ostream_t first_arg, ostream_flush_scope_t scope);
0426 extern void html_ostream_free (html_ostream_t first_arg);
0427 extern void html_ostream_begin_span (html_ostream_t first_arg, const char *classname);
0428 extern void html_ostream_end_span (html_ostream_t first_arg, const char *classname);
0429 extern const char *html_ostream_get_hyperlink_ref (html_ostream_t first_arg);
0430 extern void html_ostream_set_hyperlink_ref (html_ostream_t first_arg, const char *ref);
0431
0432
0433
0434
0435
0436
0437 extern void html_ostream_flush_to_current_style (html_ostream_t stream);
0438
0439 extern ostream_t html_ostream_get_destination (html_ostream_t stream);
0440 #ifdef __cplusplus
0441 }
0442 #endif
0443
0444 #ifdef __cplusplus
0445 extern "C" {
0446 #endif
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456 extern html_ostream_t html_ostream_create (ostream_t destination);
0457
0458
0459
0460 extern bool is_instance_of_html_ostream (ostream_t stream);
0461
0462
0463 #ifdef __cplusplus
0464 }
0465 #endif
0466
0467
0468
0469
0470 typedef styled_ostream_t term_styled_ostream_t;
0471
0472
0473 #ifdef __cplusplus
0474 extern "C" {
0475 #endif
0476 extern void term_styled_ostream_write_mem (term_styled_ostream_t first_arg, const void *data, size_t len);
0477 extern void term_styled_ostream_flush (term_styled_ostream_t first_arg, ostream_flush_scope_t scope);
0478 extern void term_styled_ostream_free (term_styled_ostream_t first_arg);
0479 extern void term_styled_ostream_begin_use_class (term_styled_ostream_t first_arg, const char *classname);
0480 extern void term_styled_ostream_end_use_class (term_styled_ostream_t first_arg, const char *classname);
0481 extern const char *term_styled_ostream_get_hyperlink_ref (term_styled_ostream_t first_arg);
0482 extern const char *term_styled_ostream_get_hyperlink_id (term_styled_ostream_t first_arg);
0483 extern void term_styled_ostream_set_hyperlink (term_styled_ostream_t first_arg, const char *ref, const char *id);
0484 extern void term_styled_ostream_flush_to_current_style (term_styled_ostream_t first_arg);
0485
0486 extern term_ostream_t term_styled_ostream_get_destination (term_styled_ostream_t stream);
0487 extern const char *term_styled_ostream_get_css_filename (term_styled_ostream_t stream);
0488 #ifdef __cplusplus
0489 }
0490 #endif
0491
0492 #ifdef __cplusplus
0493 extern "C" {
0494 #endif
0495
0496
0497
0498
0499
0500
0501
0502
0503 extern term_styled_ostream_t
0504 term_styled_ostream_create (int fd, const char *filename,
0505 ttyctl_t tty_control,
0506 const char *css_filename);
0507
0508
0509
0510 extern bool is_instance_of_term_styled_ostream (ostream_t stream);
0511
0512
0513 #ifdef __cplusplus
0514 }
0515 #endif
0516
0517
0518
0519
0520 typedef styled_ostream_t html_styled_ostream_t;
0521
0522
0523 #ifdef __cplusplus
0524 extern "C" {
0525 #endif
0526 extern void html_styled_ostream_write_mem (html_styled_ostream_t first_arg, const void *data, size_t len);
0527 extern void html_styled_ostream_flush (html_styled_ostream_t first_arg, ostream_flush_scope_t scope);
0528 extern void html_styled_ostream_free (html_styled_ostream_t first_arg);
0529 extern void html_styled_ostream_begin_use_class (html_styled_ostream_t first_arg, const char *classname);
0530 extern void html_styled_ostream_end_use_class (html_styled_ostream_t first_arg, const char *classname);
0531 extern const char *html_styled_ostream_get_hyperlink_ref (html_styled_ostream_t first_arg);
0532 extern const char *html_styled_ostream_get_hyperlink_id (html_styled_ostream_t first_arg);
0533 extern void html_styled_ostream_set_hyperlink (html_styled_ostream_t first_arg, const char *ref, const char *id);
0534 extern void html_styled_ostream_flush_to_current_style (html_styled_ostream_t first_arg);
0535
0536 extern ostream_t html_styled_ostream_get_destination (html_styled_ostream_t stream);
0537 extern html_ostream_t html_styled_ostream_get_html_destination (html_styled_ostream_t stream);
0538 extern const char *html_styled_ostream_get_css_filename (html_styled_ostream_t stream);
0539 #ifdef __cplusplus
0540 }
0541 #endif
0542
0543 #ifdef __cplusplus
0544 extern "C" {
0545 #endif
0546
0547
0548
0549
0550
0551
0552 extern html_styled_ostream_t
0553 html_styled_ostream_create (ostream_t destination,
0554 const char *css_filename);
0555
0556
0557
0558 extern bool is_instance_of_html_styled_ostream (ostream_t stream);
0559
0560
0561 #ifdef __cplusplus
0562 }
0563 #endif
0564
0565
0566
0567
0568 typedef styled_ostream_t noop_styled_ostream_t;
0569
0570
0571 #ifdef __cplusplus
0572 extern "C" {
0573 #endif
0574 extern void noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len);
0575 extern void noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope);
0576 extern void noop_styled_ostream_free (noop_styled_ostream_t first_arg);
0577 extern void noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname);
0578 extern void noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname);
0579 extern const char *noop_styled_ostream_get_hyperlink_ref (noop_styled_ostream_t first_arg);
0580 extern const char *noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg);
0581 extern void noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg, const char *ref, const char *id);
0582 extern void noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg);
0583
0584 extern ostream_t noop_styled_ostream_get_destination (noop_styled_ostream_t stream);
0585 extern bool noop_styled_ostream_is_owning_destination (noop_styled_ostream_t stream);
0586 #ifdef __cplusplus
0587 }
0588 #endif
0589
0590 #ifdef __cplusplus
0591 extern "C" {
0592 #endif
0593
0594
0595
0596
0597
0598
0599
0600
0601 extern noop_styled_ostream_t
0602 noop_styled_ostream_create (ostream_t destination, bool pass_ownership);
0603
0604
0605
0606 extern bool is_instance_of_noop_styled_ostream (ostream_t stream);
0607
0608
0609 #ifdef __cplusplus
0610 }
0611 #endif
0612
0613
0614
0615 #ifdef __cplusplus
0616 extern "C" {
0617 #endif
0618
0619
0620
0621 extern LIBTEXTSTYLE_DLL_VARIABLE bool color_test_mode;
0622
0623
0624 enum color_option { color_no, color_tty, color_yes, color_html };
0625 extern LIBTEXTSTYLE_DLL_VARIABLE enum color_option color_mode;
0626
0627
0628 extern LIBTEXTSTYLE_DLL_VARIABLE const char *style_file_name;
0629
0630
0631 extern bool handle_color_option (const char *option);
0632
0633
0634 extern void handle_style_option (const char *option);
0635
0636
0637 extern void print_color_test (void);
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650 extern void style_file_prepare (const char *style_file_envvar,
0651 const char *stylesdir_envvar,
0652 const char *stylesdir_after_install,
0653 const char *default_style_file);
0654
0655
0656 #ifdef __cplusplus
0657 }
0658 #endif
0659
0660
0661
0662 #ifdef __cplusplus
0663 extern "C" {
0664 #endif
0665
0666
0667
0668
0669
0670
0671 extern styled_ostream_t
0672 styled_ostream_create (int fd, const char *filename,
0673 ttyctl_t tty_control,
0674 const char *css_filename);
0675
0676
0677 extern void libtextstyle_set_failure_exit_code (int exit_code);
0678
0679 #ifdef __cplusplus
0680 }
0681 #endif
0682
0683
0684
0685 #if defined _WIN32 && ! defined __CYGWIN__
0686
0687 # include <io.h>
0688
0689 # ifdef __cplusplus
0690 extern "C" {
0691 # endif
0692
0693 # if !((defined isatty && defined _GL_UNISTD_H) || defined GNULIB_overrides_isatty)
0694 extern int libtextstyle_isatty (int fd);
0695 # undef isatty
0696 # define isatty libtextstyle_isatty
0697 # endif
0698
0699 # ifdef __cplusplus
0700 }
0701 # endif
0702
0703 #endif
0704
0705
0706
0707 #endif