FreeBASIC  0.91.0
fb_print.h
Go to the documentation of this file.
1 #define FB_PRINT_NEWLINE 0x00000001
2 #define FB_PRINT_PAD 0x00000002
3 #define FB_PRINT_BIN_NEWLINE 0x00000004
4 #define FB_PRINT_FORCE_ADJUST 0x00000008 /* Enforce position adjustment
5  * when last character in screen
6  * buffer gets handles in a special
7  * way */
8 #define FB_PRINT_APPEND_SPACE 0x00000010
9 #define FB_PRINT_ISLAST 0x80000000 /* only for USING */
10 
11 /* Small helper function that converts the TEXT new-line flag to the BINARY
12  new-line flag. This is used by all the LPRINT functions, to allow them to
13  use the same public API like the normal PRINT functions. */
14 static __inline__ int FB_PRINT_CONVERT_BIN_NEWLINE(int mask)
15 {
16  if( mask & FB_PRINT_NEWLINE ) {
17  mask = (mask & ~FB_PRINT_NEWLINE) | FB_PRINT_BIN_NEWLINE;
18  }
19  return mask;
20 }
21 
22 /* masked bits for "high level" flags, i.e. flags that are set by the
23  BASIC PRINT command directly. */
24 #define FB_PRINT_HLMASK 0x00000003
25 
26 #define FB_PRINT_EX(handle, s, len, mask) \
27  fb_hFilePrintBufferEx( handle, s, len )
28 
29 #define FB_PRINT(fnum, s, mask) \
30  FB_PRINT_EX( FB_FILE_TO_HANDLE(fnum), s, strlen(s), 0 )
31 
32 #define FB_PRINTWSTR_EX(handle, s, len, mask) \
33  fb_hFilePrintBufferWstrEx( handle, s, len )
34 
35 #define FB_PRINTWSTR(fnum, s, mask) \
36  FB_PRINTWSTR_EX( FB_FILE_TO_HANDLE(fnum), s, fb_wstr_len(s), 0 )
37 
38 #define FB_PRINTNUM_EX(handle, val, mask, fmt, type) \
39  do { \
40  char buffer[80]; \
41  size_t len; \
42  \
43  if( mask & FB_PRINT_APPEND_SPACE ) { \
44  if( mask & FB_PRINT_BIN_NEWLINE ) \
45  len = sprintf( buffer, fmt type " " FB_BINARY_NEWLINE, val ); \
46  else if( mask & FB_PRINT_NEWLINE ) \
47  len = sprintf( buffer, fmt type " " FB_NEWLINE, val ); \
48  else \
49  len = sprintf( buffer, fmt type " ", val ); \
50  } else { \
51  if( mask & FB_PRINT_BIN_NEWLINE ) \
52  len = sprintf( buffer, fmt type FB_BINARY_NEWLINE, val ); \
53  else if( mask & FB_PRINT_NEWLINE ) \
54  len = sprintf( buffer, fmt type FB_NEWLINE, val ); \
55  else \
56  len = sprintf( buffer, fmt type, val ); \
57  } \
58  \
59  FB_PRINT_EX( handle, buffer, len, mask ); \
60  \
61  if( mask & FB_PRINT_PAD ) \
62  fb_PrintPadEx ( handle, mask ); \
63  \
64  } while (0)
65 
66 #define FB_PRINTNUM(fnum, val, mask, fmt, type) \
67  FB_PRINTNUM_EX( FB_FILE_TO_HANDLE(fnum), val, mask, fmt, type )
68 
69 #define FB_WRITENUM_EX(handle, val, mask, type ) \
70  do { \
71  char buffer[80]; \
72  size_t len; \
73  \
74  if( mask & FB_PRINT_BIN_NEWLINE ) \
75  len = sprintf( buffer, type FB_BINARY_NEWLINE, val ); \
76  else if( mask & FB_PRINT_NEWLINE ) \
77  len = sprintf( buffer, type FB_NEWLINE, val ); \
78  else \
79  len = sprintf( buffer, type ",", val ); \
80  \
81  fb_hFilePrintBufferEx( handle, buffer, len ); \
82  } while (0)
83 
84 #define FB_WRITENUM(fnum, val, mask, type) \
85  FB_WRITENUM_EX(FB_FILE_TO_HANDLE(fnum), val, mask, type)
86 
87 FBCALL void fb_PrintBuffer ( const char *s, int mask );
88 FBCALL void fb_PrintBufferEx ( const void *buffer, size_t len, int mask );
89 FBCALL void fb_PrintBufferWstrEx( const FB_WCHAR *buffer, size_t len, int mask );
90 
91 FBCALL void fb_PrintPad ( int fnum, int mask );
92  void fb_PrintPadEx ( FB_FILE *handle, int mask );
93 FBCALL void fb_PrintPadWstr ( int fnum, int mask );
94  void fb_PrintPadWstrEx ( FB_FILE *handle, int mask );
95 
96 FBCALL void fb_PrintVoid ( int fnum, int mask );
97  void fb_PrintVoidEx ( FB_FILE *handle, int mask );
98 FBCALL void fb_PrintVoidWstr ( int fnum, int mask );
99  void fb_PrintVoidWstrEx ( FB_FILE *handle, int mask );
100 
101 FBCALL void fb_PrintByte ( int fnum, char val, int mask );
102 FBCALL void fb_PrintUByte ( int fnum, unsigned char val, int mask );
103 FBCALL void fb_PrintShort ( int fnum, short val, int mask );
104 FBCALL void fb_PrintUShort ( int fnum, unsigned short val, int mask );
105 FBCALL void fb_PrintInt ( int fnum, int val, int mask );
106 FBCALL void fb_PrintUInt ( int fnum, unsigned int val, int mask );
107 FBCALL void fb_PrintLongint ( int fnum, long long val, int mask );
108 FBCALL void fb_PrintULongint ( int fnum, unsigned long long val, int mask );
109 FBCALL void fb_PrintSingle ( int fnum, float val, int mask );
110 FBCALL void fb_PrintDouble ( int fnum, double val, int mask );
111 FBCALL void fb_PrintString ( int fnum, FBSTRING *s, int mask );
112  void fb_PrintStringEx ( FB_FILE *handle, FBSTRING *s, int mask );
113 FBCALL void fb_PrintWstr ( int fnum, const FB_WCHAR *s, int mask );
114  void fb_PrintWstrEx ( FB_FILE *handle, const FB_WCHAR *s, int mask );
115 FBCALL void fb_PrintFixString ( int fnum, const char *s, int mask );
116  void fb_PrintFixStringEx ( FB_FILE *handle, const char *s, int mask );
117 
118 FBCALL int fb_LPos ( int printer_index );
119  int fb_LPrintInit ( void );
120 FBCALL void fb_LPrintVoid ( int fnum, int mask );
121 FBCALL void fb_LPrintByte ( int fnum, char val, int mask );
122 FBCALL void fb_LPrintUByte ( int fnum, unsigned char val, int mask );
123 FBCALL void fb_LPrintShort ( int fnum, short val, int mask );
124 FBCALL void fb_LPrintUShort ( int fnum, unsigned short val, int mask );
125 FBCALL void fb_LPrintInt ( int fnum, int val, int mask );
126 FBCALL void fb_LPrintUInt ( int fnum, unsigned int val, int mask );
127 FBCALL void fb_LPrintLongint ( int fnum, long long val, int mask );
128 FBCALL void fb_LPrintULongint ( int fnum, unsigned long long val, int mask );
129 FBCALL void fb_LPrintSingle ( int fnum, float val, int mask );
130 FBCALL void fb_LPrintDouble ( int fnum, double val, int mask );
131 FBCALL void fb_LPrintString ( int fnum, FBSTRING *s, int mask );
132 FBCALL void fb_LPrintWstr ( int fnum, const FB_WCHAR *s, int mask );
133 
134 FBCALL void fb_PrintTab ( int fnum, int newcol );
135 FBCALL void fb_PrintSPC ( int fnum, ssize_t n );
136 
137 FBCALL void fb_WriteVoid ( int fnum, int mask );
138 FBCALL void fb_WriteByte ( int fnum, char val, int mask );
139 FBCALL void fb_WriteUByte ( int fnum, unsigned char val, int mask );
140 FBCALL void fb_WriteShort ( int fnum, short val, int mask );
141 FBCALL void fb_WriteUShort ( int fnum, unsigned short val, int mask );
142 FBCALL void fb_WriteInt ( int fnum, int val, int mask );
143 FBCALL void fb_WriteUInt ( int fnum, unsigned int val, int mask );
144 FBCALL void fb_WriteLongint ( int fnum, long long val, int mask );
145 FBCALL void fb_WriteULongint ( int fnum, unsigned long long val, int mask );
146 FBCALL void fb_WriteSingle ( int fnum, float val, int mask );
147 FBCALL void fb_WriteDouble ( int fnum, double val, int mask );
148 FBCALL void fb_WriteString ( int fnum, FBSTRING *s, int mask );
149 FBCALL void fb_WriteWstr ( int fnum, FB_WCHAR *s, int mask );
150 FBCALL void fb_WriteFixString ( int fnum, char *s, int mask );
151 
152 FBCALL int fb_PrintUsingInit ( FBSTRING *fmtstr );
153 FBCALL int fb_PrintUsingStr ( int fnum, FBSTRING *s, int mask );
154 FBCALL int fb_PrintUsingWstr ( int fnum, FB_WCHAR *s, int mask );
155 FBCALL int fb_PrintUsingSingle ( int fnum, float value_f, int mask );
156 FBCALL int fb_PrintUsingDouble ( int fnum, double value, int mask );
157 FBCALL int fb_PrintUsingLongint( int fnum, long long val_ll, int mask );
158 FBCALL int fb_PrintUsingULongint( int fnum, unsigned long long value_ull, int mask );
159 FBCALL int fb_PrintUsingEnd ( int fnum );
160 
161 FBCALL int fb_LPrintUsingInit ( FBSTRING *fmtstr );