FreeBASIC  0.91.0
io_write_wstr.c
Go to the documentation of this file.
1 /* write [#] wstring functions */
2 
3 #include "fb.h"
4 
5 FBCALL void fb_WriteWstr( int fnum, FB_WCHAR *s, int mask )
6 {
7  const FB_WCHAR *buff;
8  ssize_t len, bufflen;
10 
11  if( s == NULL )
12  {
13  if( mask & FB_PRINT_BIN_NEWLINE )
14  fb_hFilePrintBufferWstrEx( handle, _LC("\"\"" FB_BINARY_NEWLINE), 1+1+sizeof(FB_BINARY_NEWLINE)-1 );
15  else if( mask & FB_PRINT_NEWLINE )
16  fb_hFilePrintBufferWstrEx( handle, _LC("\"\"" FB_NEWLINE), 1+1+sizeof(FB_NEWLINE)-1 );
17  else
18  fb_hFilePrintBufferWstrEx( handle, _LC("\"\","), 1+1+1 );
19  return;
20  }
21 
22  /* close quote + new-line or comma */
23  if( mask & FB_PRINT_BIN_NEWLINE )
24  {
25  buff = _LC("\"" FB_BINARY_NEWLINE);
26  bufflen = fb_wstr_Len( _LC("\"" FB_BINARY_NEWLINE) );
27  }
28  else if( mask & FB_PRINT_NEWLINE )
29  {
30  buff = _LC("\"" FB_NEWLINE);
31  bufflen = fb_wstr_Len( _LC("\"" FB_NEWLINE) );
32  }
33  else
34  {
35  buff = _LC("\",");
36  bufflen = 2;
37  }
38 
39  FB_LOCK( );
40 
41  /* open quote */
42  fb_hFilePrintBufferWstrEx( handle, _LC("\""), 1 );
43 
44  len = fb_wstr_Len( s );
45  if( len != 0 )
46  FB_PRINTWSTR_EX( handle, s, len, 0 );
47 
48  fb_hFilePrintBufferWstrEx( handle, buff, bufflen );
49 
50  FB_UNLOCK( );
51 }