alpar@1
|
1 |
/* glpenv.h (GLPK environment) */
|
alpar@1
|
2 |
|
alpar@1
|
3 |
/***********************************************************************
|
alpar@1
|
4 |
* This code is part of GLPK (GNU Linear Programming Kit).
|
alpar@1
|
5 |
*
|
alpar@1
|
6 |
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
alpar@1
|
7 |
* 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
|
alpar@1
|
8 |
* Moscow Aviation Institute, Moscow, Russia. All rights reserved.
|
alpar@1
|
9 |
* E-mail: <mao@gnu.org>.
|
alpar@1
|
10 |
*
|
alpar@1
|
11 |
* GLPK is free software: you can redistribute it and/or modify it
|
alpar@1
|
12 |
* under the terms of the GNU General Public License as published by
|
alpar@1
|
13 |
* the Free Software Foundation, either version 3 of the License, or
|
alpar@1
|
14 |
* (at your option) any later version.
|
alpar@1
|
15 |
*
|
alpar@1
|
16 |
* GLPK is distributed in the hope that it will be useful, but WITHOUT
|
alpar@1
|
17 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
alpar@1
|
18 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
alpar@1
|
19 |
* License for more details.
|
alpar@1
|
20 |
*
|
alpar@1
|
21 |
* You should have received a copy of the GNU General Public License
|
alpar@1
|
22 |
* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
|
alpar@1
|
23 |
***********************************************************************/
|
alpar@1
|
24 |
|
alpar@1
|
25 |
#ifndef GLPENV_H
|
alpar@1
|
26 |
#define GLPENV_H
|
alpar@1
|
27 |
|
alpar@1
|
28 |
#include "glpstd.h"
|
alpar@1
|
29 |
#include "glplib.h"
|
alpar@1
|
30 |
|
alpar@1
|
31 |
typedef struct ENV ENV;
|
alpar@1
|
32 |
typedef struct MEM MEM;
|
alpar@1
|
33 |
typedef struct XFILE XFILE;
|
alpar@1
|
34 |
|
alpar@1
|
35 |
#define ENV_MAGIC 0x454E5631
|
alpar@1
|
36 |
/* environment block magic value */
|
alpar@1
|
37 |
|
alpar@1
|
38 |
#define TERM_BUF_SIZE 4096
|
alpar@1
|
39 |
/* terminal output buffer size, in bytes */
|
alpar@1
|
40 |
|
alpar@1
|
41 |
#define IOERR_MSG_SIZE 1024
|
alpar@1
|
42 |
/* i/o error message buffer size, in bytes */
|
alpar@1
|
43 |
|
alpar@1
|
44 |
#define MEM_MAGIC 0x4D454D31
|
alpar@1
|
45 |
/* memory block descriptor magic value */
|
alpar@1
|
46 |
|
alpar@1
|
47 |
struct ENV
|
alpar@1
|
48 |
{ /* environment block */
|
alpar@1
|
49 |
int magic;
|
alpar@1
|
50 |
/* magic value used for debugging */
|
alpar@1
|
51 |
char version[7+1];
|
alpar@1
|
52 |
/* version string returned by the routine glp_version */
|
alpar@1
|
53 |
/*--------------------------------------------------------------*/
|
alpar@1
|
54 |
/* terminal output */
|
alpar@1
|
55 |
char *term_buf; /* char term_buf[TERM_BUF_SIZE]; */
|
alpar@1
|
56 |
/* terminal output buffer */
|
alpar@1
|
57 |
int term_out;
|
alpar@1
|
58 |
/* flag to enable/disable terminal output */
|
alpar@1
|
59 |
int (*term_hook)(void *info, const char *s);
|
alpar@1
|
60 |
/* user-defined routine to intercept terminal output */
|
alpar@1
|
61 |
void *term_info;
|
alpar@1
|
62 |
/* transit pointer (cookie) passed to the routine term_hook */
|
alpar@1
|
63 |
FILE *tee_file;
|
alpar@1
|
64 |
/* output stream used to copy terminal output */
|
alpar@1
|
65 |
/*--------------------------------------------------------------*/
|
alpar@1
|
66 |
/* error handling */
|
alpar@1
|
67 |
const char *err_file;
|
alpar@1
|
68 |
/* value of the __FILE__ macro passed to glp_error */
|
alpar@1
|
69 |
int err_line;
|
alpar@1
|
70 |
/* value of the __LINE__ macro passed to glp_error */
|
alpar@1
|
71 |
void (*err_hook)(void *info);
|
alpar@1
|
72 |
/* user-defined routine to intercept abnormal termination */
|
alpar@1
|
73 |
void *err_info;
|
alpar@1
|
74 |
/* transit pointer (cookie) passed to the routine err_hook */
|
alpar@1
|
75 |
/*--------------------------------------------------------------*/
|
alpar@1
|
76 |
/* memory allocation */
|
alpar@1
|
77 |
glp_long mem_limit;
|
alpar@1
|
78 |
/* maximal amount of memory (in bytes) available for dynamic
|
alpar@1
|
79 |
allocation */
|
alpar@1
|
80 |
MEM *mem_ptr;
|
alpar@1
|
81 |
/* pointer to the linked list of allocated memory blocks */
|
alpar@1
|
82 |
int mem_count;
|
alpar@1
|
83 |
/* total number of currently allocated memory blocks */
|
alpar@1
|
84 |
int mem_cpeak;
|
alpar@1
|
85 |
/* peak value of mem_count */
|
alpar@1
|
86 |
glp_long mem_total;
|
alpar@1
|
87 |
/* total amount of currently allocated memory (in bytes; is the
|
alpar@1
|
88 |
sum of the size field over all memory block descriptors) */
|
alpar@1
|
89 |
glp_long mem_tpeak;
|
alpar@1
|
90 |
/* peak value of mem_total */
|
alpar@1
|
91 |
/*--------------------------------------------------------------*/
|
alpar@1
|
92 |
/* stream input/output */
|
alpar@1
|
93 |
XFILE *file_ptr;
|
alpar@1
|
94 |
/* pointer to the linked list of active stream descriptors */
|
alpar@1
|
95 |
char *ioerr_msg; /* char ioerr_msg[IOERR_MSG_SIZE]; */
|
alpar@1
|
96 |
/* input/output error message buffer */
|
alpar@1
|
97 |
/*--------------------------------------------------------------*/
|
alpar@1
|
98 |
/* shared libraries support */
|
alpar@1
|
99 |
void *h_odbc;
|
alpar@1
|
100 |
/* handle to ODBC shared library */
|
alpar@1
|
101 |
void *h_mysql;
|
alpar@1
|
102 |
/* handle to MySQL shared library */
|
alpar@1
|
103 |
};
|
alpar@1
|
104 |
|
alpar@1
|
105 |
struct MEM
|
alpar@1
|
106 |
{ /* memory block descriptor */
|
alpar@1
|
107 |
int flag;
|
alpar@1
|
108 |
/* descriptor flag */
|
alpar@1
|
109 |
int size;
|
alpar@1
|
110 |
/* size of block (in bytes, including descriptor) */
|
alpar@1
|
111 |
MEM *prev;
|
alpar@1
|
112 |
/* pointer to previous memory block descriptor */
|
alpar@1
|
113 |
MEM *next;
|
alpar@1
|
114 |
/* pointer to next memory block descriptor */
|
alpar@1
|
115 |
};
|
alpar@1
|
116 |
|
alpar@1
|
117 |
struct XFILE
|
alpar@1
|
118 |
{ /* input/output stream descriptor */
|
alpar@1
|
119 |
int type;
|
alpar@1
|
120 |
/* stream handle type: */
|
alpar@1
|
121 |
#define FH_FILE 0x11 /* FILE */
|
alpar@1
|
122 |
#define FH_ZLIB 0x22 /* gzFile */
|
alpar@1
|
123 |
void *fh;
|
alpar@1
|
124 |
/* pointer to stream handle */
|
alpar@1
|
125 |
XFILE *prev;
|
alpar@1
|
126 |
/* pointer to previous stream descriptor */
|
alpar@1
|
127 |
XFILE *next;
|
alpar@1
|
128 |
/* pointer to next stream descriptor */
|
alpar@1
|
129 |
};
|
alpar@1
|
130 |
|
alpar@1
|
131 |
#define XEOF (-1)
|
alpar@1
|
132 |
|
alpar@1
|
133 |
#define get_env_ptr _glp_get_env_ptr
|
alpar@1
|
134 |
ENV *get_env_ptr(void);
|
alpar@1
|
135 |
/* retrieve pointer to environment block */
|
alpar@1
|
136 |
|
alpar@1
|
137 |
#define tls_set_ptr _glp_tls_set_ptr
|
alpar@1
|
138 |
void tls_set_ptr(void *ptr);
|
alpar@1
|
139 |
/* store global pointer in TLS */
|
alpar@1
|
140 |
|
alpar@1
|
141 |
#define tls_get_ptr _glp_tls_get_ptr
|
alpar@1
|
142 |
void *tls_get_ptr(void);
|
alpar@1
|
143 |
/* retrieve global pointer from TLS */
|
alpar@1
|
144 |
|
alpar@1
|
145 |
#define xprintf glp_printf
|
alpar@1
|
146 |
void glp_printf(const char *fmt, ...);
|
alpar@1
|
147 |
/* write formatted output to the terminal */
|
alpar@1
|
148 |
|
alpar@1
|
149 |
#define xvprintf glp_vprintf
|
alpar@1
|
150 |
void glp_vprintf(const char *fmt, va_list arg);
|
alpar@1
|
151 |
/* write formatted output to the terminal */
|
alpar@1
|
152 |
|
alpar@1
|
153 |
#ifndef GLP_ERROR_DEFINED
|
alpar@1
|
154 |
#define GLP_ERROR_DEFINED
|
alpar@1
|
155 |
typedef void (*_glp_error)(const char *fmt, ...);
|
alpar@1
|
156 |
#endif
|
alpar@1
|
157 |
|
alpar@1
|
158 |
#define xerror glp_error_(__FILE__, __LINE__)
|
alpar@1
|
159 |
_glp_error glp_error_(const char *file, int line);
|
alpar@1
|
160 |
/* display error message and terminate execution */
|
alpar@1
|
161 |
|
alpar@1
|
162 |
#define xassert(expr) \
|
alpar@1
|
163 |
((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
|
alpar@1
|
164 |
void glp_assert_(const char *expr, const char *file, int line);
|
alpar@1
|
165 |
/* check for logical condition */
|
alpar@1
|
166 |
|
alpar@1
|
167 |
#define xmalloc glp_malloc
|
alpar@1
|
168 |
void *glp_malloc(int size);
|
alpar@1
|
169 |
/* allocate memory block */
|
alpar@1
|
170 |
|
alpar@1
|
171 |
#define xcalloc glp_calloc
|
alpar@1
|
172 |
void *glp_calloc(int n, int size);
|
alpar@1
|
173 |
/* allocate memory block */
|
alpar@1
|
174 |
|
alpar@1
|
175 |
#define xfree glp_free
|
alpar@1
|
176 |
void glp_free(void *ptr);
|
alpar@1
|
177 |
/* free memory block */
|
alpar@1
|
178 |
|
alpar@1
|
179 |
#define xtime glp_time
|
alpar@1
|
180 |
glp_long glp_time(void);
|
alpar@1
|
181 |
/* determine current universal time */
|
alpar@1
|
182 |
|
alpar@1
|
183 |
#define xdifftime glp_difftime
|
alpar@1
|
184 |
double glp_difftime(glp_long t1, glp_long t0);
|
alpar@1
|
185 |
/* compute difference between two time values, in seconds */
|
alpar@1
|
186 |
|
alpar@1
|
187 |
#define lib_err_msg _glp_lib_err_msg
|
alpar@1
|
188 |
void lib_err_msg(const char *msg);
|
alpar@1
|
189 |
|
alpar@1
|
190 |
#define xerrmsg _glp_lib_xerrmsg
|
alpar@1
|
191 |
const char *xerrmsg(void);
|
alpar@1
|
192 |
|
alpar@1
|
193 |
#define xfopen _glp_lib_xfopen
|
alpar@1
|
194 |
XFILE *xfopen(const char *fname, const char *mode);
|
alpar@1
|
195 |
|
alpar@1
|
196 |
#define xferror _glp_lib_xferror
|
alpar@1
|
197 |
int xferror(XFILE *file);
|
alpar@1
|
198 |
|
alpar@1
|
199 |
#define xfeof _glp_lib_xfeof
|
alpar@1
|
200 |
int xfeof(XFILE *file);
|
alpar@1
|
201 |
|
alpar@1
|
202 |
#define xfgetc _glp_lib_xfgetc
|
alpar@1
|
203 |
int xfgetc(XFILE *file);
|
alpar@1
|
204 |
|
alpar@1
|
205 |
#define xfputc _glp_lib_xfputc
|
alpar@1
|
206 |
int xfputc(int c, XFILE *file);
|
alpar@1
|
207 |
|
alpar@1
|
208 |
#define xfflush _glp_lib_xfflush
|
alpar@1
|
209 |
int xfflush(XFILE *fp);
|
alpar@1
|
210 |
|
alpar@1
|
211 |
#define xfclose _glp_lib_xfclose
|
alpar@1
|
212 |
int xfclose(XFILE *file);
|
alpar@1
|
213 |
|
alpar@1
|
214 |
#define xfprintf _glp_lib_xfprintf
|
alpar@1
|
215 |
int xfprintf(XFILE *file, const char *fmt, ...);
|
alpar@1
|
216 |
|
alpar@1
|
217 |
#define xdlopen _glp_xdlopen
|
alpar@1
|
218 |
void *xdlopen(const char *module);
|
alpar@1
|
219 |
|
alpar@1
|
220 |
#define xdlsym _glp_xdlsym
|
alpar@1
|
221 |
void *xdlsym(void *h, const char *symbol);
|
alpar@1
|
222 |
|
alpar@1
|
223 |
#define xdlclose _glp_xdlclose
|
alpar@1
|
224 |
void xdlclose(void *h);
|
alpar@1
|
225 |
|
alpar@1
|
226 |
#endif
|
alpar@1
|
227 |
|
alpar@1
|
228 |
/* eof */
|