1 /* writer.h                                        -*- mode:c; coding:utf-8; -*-
2  *
3  *   Copyright (c) 2010-2021  Takashi Kato <ktakashi@ymail.com>
4  *
5  *   Redistribution and use in source and binary forms, with or without
6  *   modification, are permitted provided that the following conditions
7  *   are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *
16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *  $Id: $
29  */
30 #ifndef SAGITTARIUS_PRIVATE_WRITER_H_
31 #define SAGITTARIUS_PRIVATE_WRITER_H_
32 
33 #include "sagittariusdefs.h"
34 
35 struct SgWriteContextRec
36 {
37   short mode;                 /* print mode */
38   short flags;                /* internal */
39   int sharedId;		      /* internal */
40   long limit;		      /* internal */
41   int ncirc;                  /* internal */
42   SgHashTable *table;         /* internal */
43   int stackSize;	      /* internal */
44 };
45 
46 /* Print mode flags */
47 enum {
48     SG_WRITE_WRITE   = 0,      /* write mode   */
49     SG_WRITE_DISPLAY = 1,      /* display mode */
50     SG_WRITE_SHARED  = 2,      /* write/ss mode   */
51     SG_WRITE_LIBPATH = 3,      /* only for %L */
52     SG_WRITE_MODE_MASK = 0x3,
53 
54 #if 0
55     /* should i make case insensitive mode? */
56     SG_WRITE_CASE_FOLD = 4,    /* case-fold mode.  need to escape capital
57 				  letters. */
58     SG_WRITE_CASE_NOFOLD = 8,  /* case-sensitive mode.  no need to escape
59 				  capital letters */
60     SG_WRITE_CASE_MASK = 0x0c
61 #endif
62 };
63 
64 #define SG_WRITE_MODE(ctx)  ((ctx)->mode & SG_WRITE_MODE_MASK)
65 
66 SG_CDECL_BEGIN
67 
68 SG_EXTERN void 	   Sg_Write(SgObject obj, SgObject port, int mode);
69 SG_EXTERN long     Sg_WriteCircular(SgObject obj, SgObject port,
70 				    int mode, long width);
71 SG_EXTERN long     Sg_WriteLimited(SgObject obj, SgObject port,
72 				   int mode, long width);
73 SG_EXTERN void 	   Sg_Format(SgPort *port, SgString *fmt,
74 			     SgObject args, int ss);
75 SG_EXTERN void 	   Sg_Printf(SgPort *port, const SgChar *fmt, ...);
76 SG_EXTERN void 	   Sg_PrintfShared(SgPort *port, const SgChar *fmt, ...);
77 SG_EXTERN void 	   Sg_Vprintf(SgPort *port, const SgChar *fmt, va_list args,
78 			       int sharedp);
79 SG_EXTERN SgObject Sg_Sprintf(const SgChar *fmt, ...);
80 SG_EXTERN SgObject Sg_SprintfShared(const SgChar *fmt, ...);
81 SG_EXTERN SgObject Sg_Vsprintf(const SgChar *fmt, va_list args, int sharedp);
82 
83 /* for convenience */
84 SG_EXTERN void     Sg_WriteSymbolName(SgString *snam, SgPort *port,
85 				      SgWriteContext *ctx, int flags);
86 
87 SG_CDECL_END
88 
89 #endif /* SAGITTARIUS_WRITER_H_ */
90 
91 /*
92   end of file
93   Local Variables:
94   coding: utf-8-unix
95   End
96 */
97