lemon-project-template-glpk
view deps/glpk/src/glpenv.h @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
line source
1 /* glpenv.h (GLPK environment) */
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, 2011 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
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 ***********************************************************************/
25 #ifndef GLPENV_H
26 #define GLPENV_H
28 #include "glpstd.h"
29 #include "glplib.h"
31 typedef struct ENV ENV;
32 typedef struct MEM MEM;
33 typedef struct XFILE XFILE;
35 #define ENV_MAGIC 0x454E5631
36 /* environment block magic value */
38 #define TERM_BUF_SIZE 4096
39 /* terminal output buffer size, in bytes */
41 #define IOERR_MSG_SIZE 1024
42 /* i/o error message buffer size, in bytes */
44 #define MEM_MAGIC 0x4D454D31
45 /* memory block descriptor magic value */
47 struct ENV
48 { /* environment block */
49 int magic;
50 /* magic value used for debugging */
51 char version[7+1];
52 /* version string returned by the routine glp_version */
53 /*--------------------------------------------------------------*/
54 /* terminal output */
55 char *term_buf; /* char term_buf[TERM_BUF_SIZE]; */
56 /* terminal output buffer */
57 int term_out;
58 /* flag to enable/disable terminal output */
59 int (*term_hook)(void *info, const char *s);
60 /* user-defined routine to intercept terminal output */
61 void *term_info;
62 /* transit pointer (cookie) passed to the routine term_hook */
63 FILE *tee_file;
64 /* output stream used to copy terminal output */
65 /*--------------------------------------------------------------*/
66 /* error handling */
67 const char *err_file;
68 /* value of the __FILE__ macro passed to glp_error */
69 int err_line;
70 /* value of the __LINE__ macro passed to glp_error */
71 void (*err_hook)(void *info);
72 /* user-defined routine to intercept abnormal termination */
73 void *err_info;
74 /* transit pointer (cookie) passed to the routine err_hook */
75 /*--------------------------------------------------------------*/
76 /* memory allocation */
77 glp_long mem_limit;
78 /* maximal amount of memory (in bytes) available for dynamic
79 allocation */
80 MEM *mem_ptr;
81 /* pointer to the linked list of allocated memory blocks */
82 int mem_count;
83 /* total number of currently allocated memory blocks */
84 int mem_cpeak;
85 /* peak value of mem_count */
86 glp_long mem_total;
87 /* total amount of currently allocated memory (in bytes; is the
88 sum of the size field over all memory block descriptors) */
89 glp_long mem_tpeak;
90 /* peak value of mem_total */
91 /*--------------------------------------------------------------*/
92 /* stream input/output */
93 XFILE *file_ptr;
94 /* pointer to the linked list of active stream descriptors */
95 char *ioerr_msg; /* char ioerr_msg[IOERR_MSG_SIZE]; */
96 /* input/output error message buffer */
97 /*--------------------------------------------------------------*/
98 /* shared libraries support */
99 void *h_odbc;
100 /* handle to ODBC shared library */
101 void *h_mysql;
102 /* handle to MySQL shared library */
103 };
105 struct MEM
106 { /* memory block descriptor */
107 int flag;
108 /* descriptor flag */
109 int size;
110 /* size of block (in bytes, including descriptor) */
111 MEM *prev;
112 /* pointer to previous memory block descriptor */
113 MEM *next;
114 /* pointer to next memory block descriptor */
115 };
117 struct XFILE
118 { /* input/output stream descriptor */
119 int type;
120 /* stream handle type: */
121 #define FH_FILE 0x11 /* FILE */
122 #define FH_ZLIB 0x22 /* gzFile */
123 void *fh;
124 /* pointer to stream handle */
125 XFILE *prev;
126 /* pointer to previous stream descriptor */
127 XFILE *next;
128 /* pointer to next stream descriptor */
129 };
131 #define XEOF (-1)
133 #define get_env_ptr _glp_get_env_ptr
134 ENV *get_env_ptr(void);
135 /* retrieve pointer to environment block */
137 #define tls_set_ptr _glp_tls_set_ptr
138 void tls_set_ptr(void *ptr);
139 /* store global pointer in TLS */
141 #define tls_get_ptr _glp_tls_get_ptr
142 void *tls_get_ptr(void);
143 /* retrieve global pointer from TLS */
145 #define xprintf glp_printf
146 void glp_printf(const char *fmt, ...);
147 /* write formatted output to the terminal */
149 #define xvprintf glp_vprintf
150 void glp_vprintf(const char *fmt, va_list arg);
151 /* write formatted output to the terminal */
153 #ifndef GLP_ERROR_DEFINED
154 #define GLP_ERROR_DEFINED
155 typedef void (*_glp_error)(const char *fmt, ...);
156 #endif
158 #define xerror glp_error_(__FILE__, __LINE__)
159 _glp_error glp_error_(const char *file, int line);
160 /* display error message and terminate execution */
162 #define xassert(expr) \
163 ((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
164 void glp_assert_(const char *expr, const char *file, int line);
165 /* check for logical condition */
167 #define xmalloc glp_malloc
168 void *glp_malloc(int size);
169 /* allocate memory block */
171 #define xcalloc glp_calloc
172 void *glp_calloc(int n, int size);
173 /* allocate memory block */
175 #define xfree glp_free
176 void glp_free(void *ptr);
177 /* free memory block */
179 #define xtime glp_time
180 glp_long glp_time(void);
181 /* determine current universal time */
183 #define xdifftime glp_difftime
184 double glp_difftime(glp_long t1, glp_long t0);
185 /* compute difference between two time values, in seconds */
187 #define lib_err_msg _glp_lib_err_msg
188 void lib_err_msg(const char *msg);
190 #define xerrmsg _glp_lib_xerrmsg
191 const char *xerrmsg(void);
193 #define xfopen _glp_lib_xfopen
194 XFILE *xfopen(const char *fname, const char *mode);
196 #define xferror _glp_lib_xferror
197 int xferror(XFILE *file);
199 #define xfeof _glp_lib_xfeof
200 int xfeof(XFILE *file);
202 #define xfgetc _glp_lib_xfgetc
203 int xfgetc(XFILE *file);
205 #define xfputc _glp_lib_xfputc
206 int xfputc(int c, XFILE *file);
208 #define xfflush _glp_lib_xfflush
209 int xfflush(XFILE *fp);
211 #define xfclose _glp_lib_xfclose
212 int xfclose(XFILE *file);
214 #define xfprintf _glp_lib_xfprintf
215 int xfprintf(XFILE *file, const char *fmt, ...);
217 #define xdlopen _glp_xdlopen
218 void *xdlopen(const char *module);
220 #define xdlsym _glp_xdlsym
221 void *xdlsym(void *h, const char *symbol);
223 #define xdlclose _glp_xdlclose
224 void xdlclose(void *h);
226 #endif
228 /* eof */