Debian Codegraph @

external/glpk/glpenv03.c

raw symbols SCIP
1 /* glpenv03.c (terminal output) */cxx . . $ `<file>/external/glpk/glpenv03.c`/
2
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
5 *
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <[email protected]>.
10 *
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
24
25 #include "glpapi.h"cxx . . $ `<file>/external/glpk/glpapi.h`/
26
27 /***********************************************************************
28 * NAME
29 *
30 * glp_printf - write formatted output to terminal
31 *
32 * SYNOPSIS
33 *
34 * void glp_printf(const char *fmt, ...);
35 *
36 * DESCRIPTION
37 *
38 * The routine glp_printf uses the format control string fmt to format
39 * its parameters and writes the formatted output to the terminal. */
40
41 void glp_printfcxx . . $ glp_printf(326aeb464d16410c).(const char *fmt, ...)
42 { va_listcxx . . $ va_list# arg;
43 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(arg, fmt);
44 xvprintfcxx . . $ `external/glpk/glpenv.h:149:9`!(fmt, arg);
45 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(arg);
46 return;
47 }
48
49 /***********************************************************************
50 * NAME
51 *
52 * glp_vprintf - write formatted output to terminal
53 *
54 * SYNOPSIS
55 *
56 * void glp_vprintf(const char *fmt, va_list arg);
57 *
58 * DESCRIPTION
59 *
60 * The routine glp_vprintf uses the format control string fmt to format
61 * its parameters specified by the list arg and writes the formatted
62 * output to the terminal. */
63
64 void glp_vprintfcxx . . $ glp_vprintf(ac175dd46a4e4d7f).(const char *fmt, va_listcxx . . $ va_list# arg)
65 { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!();
66 /* if terminal output is disabled, do nothing */
67 if (!env->term_outcxx . . $ ENV#term_out.) goto skip;
68 /* format the output */
69 vsprintfcxx . . $ vsprintf(d8921982374e5df0).(env->term_bufcxx . . $ ENV#term_buf., fmt, arg);
70 /* pass the output to the user-defined routine */
71 if (env->term_hookcxx . . $ ENV#term_hook. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
72 { if (env->term_hookcxx . . $ ENV#term_hook.(env->term_infocxx . . $ ENV#term_info., env->term_bufcxx . . $ ENV#term_buf.) != 0)
73 goto skip;
74 }
75 /* send the output to the terminal */
76 fputscxx . . $ fputs(874fa6a5e59ab9bd).(env->term_bufcxx . . $ ENV#term_buf., stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
77 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
78 /* copy the output to the text file */
79 if (env->tee_filecxx . . $ ENV#tee_file. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
80 { fputscxx . . $ fputs(874fa6a5e59ab9bd).(env->term_bufcxx . . $ ENV#term_buf., env->tee_filecxx . . $ ENV#tee_file.);
81 fflushcxx . . $ fflush(89bc1efcdac0ca22).(env->tee_filecxx . . $ ENV#tee_file.);
82 }
83 skip: return;
84 }
85
86 /***********************************************************************
87 * NAME
88 *
89 * glp_term_out - enable/disable terminal output
90 *
91 * SYNOPSIS
92 *
93 * int glp_term_out(int flag);
94 *
95 * DESCRIPTION
96 *
97 * Depending on the parameter flag the routine glp_term_out enables or
98 * disables terminal output performed by glpk routines:
99 *
100 * GLP_ON - enable terminal output;
101 * GLP_OFF - disable terminal output.
102 *
103 * RETURNS
104 *
105 * The routine glp_term_out returns the previous value of the terminal
106 * output flag. */
107
108 int glp_term_outcxx . . $ glp_term_out(7864480464b09eea).(int flag)
109 { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!();
110 int old = env->term_outcxx . . $ ENV#term_out.;
111 if (!(flag == GLP_ONcxx . . $ `external/glpk/glpk.h:221:9`! || flag == GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!))
112 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_term_out: flag = %d; invalid value\n", flag);
113 env->term_outcxx . . $ ENV#term_out. = flag;
114 return old;
115 }
116
117 /***********************************************************************
118 * NAME
119 *
120 * glp_term_hook - install hook to intercept terminal output
121 *
122 * SYNOPSIS
123 *
124 * void glp_term_hook(int (*func)(void *info, const char *s),
125 * void *info);
126 *
127 * DESCRIPTION
128 *
129 * The routine glp_term_hook installs a user-defined hook routine to
130 * intercept all terminal output performed by glpk routines.
131 *
132 * This feature can be used to redirect the terminal output to other
133 * destination, for example to a file or a text window.
134 *
135 * The parameter func specifies the user-defined hook routine. It is
136 * called from an internal printing routine, which passes to it two
137 * parameters: info and s. The parameter info is a transit pointer,
138 * specified in the corresponding call to the routine glp_term_hook;
139 * it may be used to pass some information to the hook routine. The
140 * parameter s is a pointer to the null terminated character string,
141 * which is intended to be written to the terminal. If the hook routine
142 * returns zero, the printing routine writes the string s to the
143 * terminal in a usual way; otherwise, if the hook routine returns
144 * non-zero, no terminal output is performed.
145 *
146 * To uninstall the hook routine the parameters func and info should be
147 * specified as NULL. */
148
149 void glp_term_hookcxx . . $ glp_term_hook(e93a814f84a02f57).(int (*func)(void *info, const char *s), void *info)
150 { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!();
151 if (func == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
152 { env->term_hookcxx . . $ ENV#term_hook. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
153 env->term_infocxx . . $ ENV#term_info. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
154 }
155 else
156 { env->term_hookcxx . . $ ENV#term_hook. = func;
157 env->term_infocxx . . $ ENV#term_info. = info;
158 }
159 return;
160 }
161
162 /***********************************************************************
163 * NAME
164 *
165 * glp_open_tee - start copying terminal output to text file
166 *
167 * SYNOPSIS
168 *
169 * int glp_open_tee(const char *fname);
170 *
171 * DESCRIPTION
172 *
173 * The routine glp_open_tee starts copying all the terminal output to
174 * an output text file, whose name is specified by the character string
175 * fname.
176 *
177 * RETURNS
178 *
179 * 0 - operation successful
180 * 1 - copying terminal output is already active
181 * 2 - unable to create output file */
182
183 int glp_open_teecxx . . $ glp_open_tee(5c4306d8553b3696).(const char *fname)
184 { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!();
185 if (env->tee_filecxx . . $ ENV#tee_file. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
186 { /* copying terminal output is already active */
187 return 1;
188 }
189 env->tee_filecxx . . $ ENV#tee_file. = fopencxx . . $ fopen(82ec0787cd37e0a3).(fname, "w");
190 if (env->tee_filecxx . . $ ENV#tee_file. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
191 { /* unable to create output file */
192 return 2;
193 }
194 return 0;
195 }
196
197 /***********************************************************************
198 * NAME
199 *
200 * glp_close_tee - stop copying terminal output to text file
201 *
202 * SYNOPSIS
203 *
204 * int glp_close_tee(void);
205 *
206 * DESCRIPTION
207 *
208 * The routine glp_close_tee stops copying the terminal output to the
209 * output text file previously open by the routine glp_open_tee closing
210 * that file.
211 *
212 * RETURNS
213 *
214 * 0 - operation successful
215 * 1 - copying terminal output was not started */
216
217 int glp_close_teecxx . . $ glp_close_tee(b126dc7c1de90089).(void)
218 { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!();
219 if (env->tee_filecxx . . $ ENV#tee_file. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
220 { /* copying terminal output was not started */
221 return 1;
222 }
223 fclosecxx . . $ fclose(89bc1efcdac0ca22).(env->tee_filecxx . . $ ENV#tee_file.);
224 env->tee_filecxx . . $ ENV#tee_file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
225 return 0;
226 }
227
228 /* eof */