1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/glpenv.h Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,228 @@
1.4 +/* glpenv.h (GLPK environment) */
1.5 +
1.6 +/***********************************************************************
1.7 +* This code is part of GLPK (GNU Linear Programming Kit).
1.8 +*
1.9 +* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
1.10 +* 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
1.11 +* Moscow Aviation Institute, Moscow, Russia. All rights reserved.
1.12 +* E-mail: <mao@gnu.org>.
1.13 +*
1.14 +* GLPK is free software: you can redistribute it and/or modify it
1.15 +* under the terms of the GNU General Public License as published by
1.16 +* the Free Software Foundation, either version 3 of the License, or
1.17 +* (at your option) any later version.
1.18 +*
1.19 +* GLPK is distributed in the hope that it will be useful, but WITHOUT
1.20 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.21 +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1.22 +* License for more details.
1.23 +*
1.24 +* You should have received a copy of the GNU General Public License
1.25 +* along with GLPK. If not, see <http://www.gnu.org/licenses/>.
1.26 +***********************************************************************/
1.27 +
1.28 +#ifndef GLPENV_H
1.29 +#define GLPENV_H
1.30 +
1.31 +#include "glpstd.h"
1.32 +#include "glplib.h"
1.33 +
1.34 +typedef struct ENV ENV;
1.35 +typedef struct MEM MEM;
1.36 +typedef struct XFILE XFILE;
1.37 +
1.38 +#define ENV_MAGIC 0x454E5631
1.39 +/* environment block magic value */
1.40 +
1.41 +#define TERM_BUF_SIZE 4096
1.42 +/* terminal output buffer size, in bytes */
1.43 +
1.44 +#define IOERR_MSG_SIZE 1024
1.45 +/* i/o error message buffer size, in bytes */
1.46 +
1.47 +#define MEM_MAGIC 0x4D454D31
1.48 +/* memory block descriptor magic value */
1.49 +
1.50 +struct ENV
1.51 +{ /* environment block */
1.52 + int magic;
1.53 + /* magic value used for debugging */
1.54 + char version[7+1];
1.55 + /* version string returned by the routine glp_version */
1.56 + /*--------------------------------------------------------------*/
1.57 + /* terminal output */
1.58 + char *term_buf; /* char term_buf[TERM_BUF_SIZE]; */
1.59 + /* terminal output buffer */
1.60 + int term_out;
1.61 + /* flag to enable/disable terminal output */
1.62 + int (*term_hook)(void *info, const char *s);
1.63 + /* user-defined routine to intercept terminal output */
1.64 + void *term_info;
1.65 + /* transit pointer (cookie) passed to the routine term_hook */
1.66 + FILE *tee_file;
1.67 + /* output stream used to copy terminal output */
1.68 + /*--------------------------------------------------------------*/
1.69 + /* error handling */
1.70 + const char *err_file;
1.71 + /* value of the __FILE__ macro passed to glp_error */
1.72 + int err_line;
1.73 + /* value of the __LINE__ macro passed to glp_error */
1.74 + void (*err_hook)(void *info);
1.75 + /* user-defined routine to intercept abnormal termination */
1.76 + void *err_info;
1.77 + /* transit pointer (cookie) passed to the routine err_hook */
1.78 + /*--------------------------------------------------------------*/
1.79 + /* memory allocation */
1.80 + glp_long mem_limit;
1.81 + /* maximal amount of memory (in bytes) available for dynamic
1.82 + allocation */
1.83 + MEM *mem_ptr;
1.84 + /* pointer to the linked list of allocated memory blocks */
1.85 + int mem_count;
1.86 + /* total number of currently allocated memory blocks */
1.87 + int mem_cpeak;
1.88 + /* peak value of mem_count */
1.89 + glp_long mem_total;
1.90 + /* total amount of currently allocated memory (in bytes; is the
1.91 + sum of the size field over all memory block descriptors) */
1.92 + glp_long mem_tpeak;
1.93 + /* peak value of mem_total */
1.94 + /*--------------------------------------------------------------*/
1.95 + /* stream input/output */
1.96 + XFILE *file_ptr;
1.97 + /* pointer to the linked list of active stream descriptors */
1.98 + char *ioerr_msg; /* char ioerr_msg[IOERR_MSG_SIZE]; */
1.99 + /* input/output error message buffer */
1.100 + /*--------------------------------------------------------------*/
1.101 + /* shared libraries support */
1.102 + void *h_odbc;
1.103 + /* handle to ODBC shared library */
1.104 + void *h_mysql;
1.105 + /* handle to MySQL shared library */
1.106 +};
1.107 +
1.108 +struct MEM
1.109 +{ /* memory block descriptor */
1.110 + int flag;
1.111 + /* descriptor flag */
1.112 + int size;
1.113 + /* size of block (in bytes, including descriptor) */
1.114 + MEM *prev;
1.115 + /* pointer to previous memory block descriptor */
1.116 + MEM *next;
1.117 + /* pointer to next memory block descriptor */
1.118 +};
1.119 +
1.120 +struct XFILE
1.121 +{ /* input/output stream descriptor */
1.122 + int type;
1.123 + /* stream handle type: */
1.124 +#define FH_FILE 0x11 /* FILE */
1.125 +#define FH_ZLIB 0x22 /* gzFile */
1.126 + void *fh;
1.127 + /* pointer to stream handle */
1.128 + XFILE *prev;
1.129 + /* pointer to previous stream descriptor */
1.130 + XFILE *next;
1.131 + /* pointer to next stream descriptor */
1.132 +};
1.133 +
1.134 +#define XEOF (-1)
1.135 +
1.136 +#define get_env_ptr _glp_get_env_ptr
1.137 +ENV *get_env_ptr(void);
1.138 +/* retrieve pointer to environment block */
1.139 +
1.140 +#define tls_set_ptr _glp_tls_set_ptr
1.141 +void tls_set_ptr(void *ptr);
1.142 +/* store global pointer in TLS */
1.143 +
1.144 +#define tls_get_ptr _glp_tls_get_ptr
1.145 +void *tls_get_ptr(void);
1.146 +/* retrieve global pointer from TLS */
1.147 +
1.148 +#define xprintf glp_printf
1.149 +void glp_printf(const char *fmt, ...);
1.150 +/* write formatted output to the terminal */
1.151 +
1.152 +#define xvprintf glp_vprintf
1.153 +void glp_vprintf(const char *fmt, va_list arg);
1.154 +/* write formatted output to the terminal */
1.155 +
1.156 +#ifndef GLP_ERROR_DEFINED
1.157 +#define GLP_ERROR_DEFINED
1.158 +typedef void (*_glp_error)(const char *fmt, ...);
1.159 +#endif
1.160 +
1.161 +#define xerror glp_error_(__FILE__, __LINE__)
1.162 +_glp_error glp_error_(const char *file, int line);
1.163 +/* display error message and terminate execution */
1.164 +
1.165 +#define xassert(expr) \
1.166 + ((void)((expr) || (glp_assert_(#expr, __FILE__, __LINE__), 1)))
1.167 +void glp_assert_(const char *expr, const char *file, int line);
1.168 +/* check for logical condition */
1.169 +
1.170 +#define xmalloc glp_malloc
1.171 +void *glp_malloc(int size);
1.172 +/* allocate memory block */
1.173 +
1.174 +#define xcalloc glp_calloc
1.175 +void *glp_calloc(int n, int size);
1.176 +/* allocate memory block */
1.177 +
1.178 +#define xfree glp_free
1.179 +void glp_free(void *ptr);
1.180 +/* free memory block */
1.181 +
1.182 +#define xtime glp_time
1.183 +glp_long glp_time(void);
1.184 +/* determine current universal time */
1.185 +
1.186 +#define xdifftime glp_difftime
1.187 +double glp_difftime(glp_long t1, glp_long t0);
1.188 +/* compute difference between two time values, in seconds */
1.189 +
1.190 +#define lib_err_msg _glp_lib_err_msg
1.191 +void lib_err_msg(const char *msg);
1.192 +
1.193 +#define xerrmsg _glp_lib_xerrmsg
1.194 +const char *xerrmsg(void);
1.195 +
1.196 +#define xfopen _glp_lib_xfopen
1.197 +XFILE *xfopen(const char *fname, const char *mode);
1.198 +
1.199 +#define xferror _glp_lib_xferror
1.200 +int xferror(XFILE *file);
1.201 +
1.202 +#define xfeof _glp_lib_xfeof
1.203 +int xfeof(XFILE *file);
1.204 +
1.205 +#define xfgetc _glp_lib_xfgetc
1.206 +int xfgetc(XFILE *file);
1.207 +
1.208 +#define xfputc _glp_lib_xfputc
1.209 +int xfputc(int c, XFILE *file);
1.210 +
1.211 +#define xfflush _glp_lib_xfflush
1.212 +int xfflush(XFILE *fp);
1.213 +
1.214 +#define xfclose _glp_lib_xfclose
1.215 +int xfclose(XFILE *file);
1.216 +
1.217 +#define xfprintf _glp_lib_xfprintf
1.218 +int xfprintf(XFILE *file, const char *fmt, ...);
1.219 +
1.220 +#define xdlopen _glp_xdlopen
1.221 +void *xdlopen(const char *module);
1.222 +
1.223 +#define xdlsym _glp_xdlsym
1.224 +void *xdlsym(void *h, const char *symbol);
1.225 +
1.226 +#define xdlclose _glp_xdlclose
1.227 +void xdlclose(void *h);
1.228 +
1.229 +#endif
1.230 +
1.231 +/* eof */