COIN-OR::LEMON - Graph Library

source: lemon-project-template-glpk/deps/glpk/src/glpenv.h @ 10:5545663ca997

subpack-glpk
Last change on this file since 10:5545663ca997 was 9:33de93886c88, checked in by Alpar Juttner <alpar@…>, 13 years ago

Import GLPK 4.47

File size: 6.8 KB
RevLine 
[9]1/* glpenv.h (GLPK environment) */
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, 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***********************************************************************/
24
25#ifndef GLPENV_H
26#define GLPENV_H
27
28#include "glpstd.h"
29#include "glplib.h"
30
31typedef struct ENV ENV;
32typedef struct MEM MEM;
33typedef struct XFILE XFILE;
34
35#define ENV_MAGIC 0x454E5631
36/* environment block magic value */
37
38#define TERM_BUF_SIZE 4096
39/* terminal output buffer size, in bytes */
40
41#define IOERR_MSG_SIZE 1024
42/* i/o error message buffer size, in bytes */
43
44#define MEM_MAGIC 0x4D454D31
45/* memory block descriptor magic value */
46
47struct 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};
104
105struct 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};
116
117struct 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};
130
131#define XEOF (-1)
132
133#define get_env_ptr _glp_get_env_ptr
134ENV *get_env_ptr(void);
135/* retrieve pointer to environment block */
136
137#define tls_set_ptr _glp_tls_set_ptr
138void tls_set_ptr(void *ptr);
139/* store global pointer in TLS */
140
141#define tls_get_ptr _glp_tls_get_ptr
142void *tls_get_ptr(void);
143/* retrieve global pointer from TLS */
144
145#define xprintf glp_printf
146void glp_printf(const char *fmt, ...);
147/* write formatted output to the terminal */
148
149#define xvprintf glp_vprintf
150void glp_vprintf(const char *fmt, va_list arg);
151/* write formatted output to the terminal */
152
153#ifndef GLP_ERROR_DEFINED
154#define GLP_ERROR_DEFINED
155typedef void (*_glp_error)(const char *fmt, ...);
156#endif
157
158#define xerror glp_error_(__FILE__, __LINE__)
159_glp_error glp_error_(const char *file, int line);
160/* display error message and terminate execution */
161
162#define xassert(expr) \
163      ((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
164void glp_assert_(const char *expr, const char *file, int line);
165/* check for logical condition */
166
167#define xmalloc glp_malloc
168void *glp_malloc(int size);
169/* allocate memory block */
170
171#define xcalloc glp_calloc
172void *glp_calloc(int n, int size);
173/* allocate memory block */
174
175#define xfree glp_free
176void glp_free(void *ptr);
177/* free memory block */
178
179#define xtime glp_time
180glp_long glp_time(void);
181/* determine current universal time */
182
183#define xdifftime glp_difftime
184double glp_difftime(glp_long t1, glp_long t0);
185/* compute difference between two time values, in seconds */
186
187#define lib_err_msg _glp_lib_err_msg
188void lib_err_msg(const char *msg);
189
190#define xerrmsg _glp_lib_xerrmsg
191const char *xerrmsg(void);
192
193#define xfopen _glp_lib_xfopen
194XFILE *xfopen(const char *fname, const char *mode);
195
196#define xferror _glp_lib_xferror
197int xferror(XFILE *file);
198
199#define xfeof _glp_lib_xfeof
200int xfeof(XFILE *file);
201
202#define xfgetc _glp_lib_xfgetc
203int xfgetc(XFILE *file);
204
205#define xfputc _glp_lib_xfputc
206int xfputc(int c, XFILE *file);
207
208#define xfflush _glp_lib_xfflush
209int xfflush(XFILE *fp);
210
211#define xfclose _glp_lib_xfclose
212int xfclose(XFILE *file);
213
214#define xfprintf _glp_lib_xfprintf
215int xfprintf(XFILE *file, const char *fmt, ...);
216
217#define xdlopen _glp_xdlopen
218void *xdlopen(const char *module);
219
220#define xdlsym _glp_xdlsym
221void *xdlsym(void *h, const char *symbol);
222
223#define xdlclose _glp_xdlclose
224void xdlclose(void *h);
225
226#endif
227
228/* eof */
Note: See TracBrowser for help on using the repository browser.