PageRenderTime 39ms CodeModel.GetById 19ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/farmR/src/glplib.h

https://code.google.com/p/javawfm/
C++ Header | 379 lines | 193 code | 80 blank | 106 comment | 1 complexity | d3fe2597f3494f7e1ae1e534464b0bd0 MD5 | raw file
  1/* glplib.h (low-level library routines) */
  2
  3/***********************************************************************
  4*  This code is part of GLPK (GNU Linear Programming Kit).
  5*
  6*  Copyright (C) 2000,01,02,03,04,05,06,07,08,2009 Andrew Makhorin,
  7*  Department for Applied Informatics, Moscow Aviation Institute,
  8*  Moscow, Russia. All rights reserved. E-mail: <mao@mai2.rcnet.ru>.
  9*
 10*  GLPK is free software: you can redistribute it and/or modify it
 11*  under the terms of the GNU General Public License as published by
 12*  the Free Software Foundation, either version 3 of the License, or
 13*  (at your option) any later version.
 14*
 15*  GLPK is distributed in the hope that it will be useful, but WITHOUT
 16*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 17*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
 18*  License for more details.
 19*
 20*  You should have received a copy of the GNU General Public License
 21*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
 22***********************************************************************/
 23
 24#ifndef _GLPLIB_H
 25#define _GLPLIB_H
 26
 27#ifdef HAVE_CONFIG_H
 28#include <config.h>
 29#endif
 30
 31#include "glpstd.h"
 32
 33typedef struct { int lo, hi; } xlong_t;
 34/* long integer data type */
 35
 36typedef struct { xlong_t quot, rem; } xldiv_t;
 37/* result of long integer division */
 38
 39typedef struct LIBENV LIBENV;
 40typedef struct LIBMEM LIBMEM;
 41typedef struct XFILE XFILE;
 42
 43struct LIBENV
 44{     /* library environment block */
 45      char version[7+1];
 46      /* version string returned by the routine glp_version */
 47      /*--------------------------------------------------------------*/
 48      /* memory allocation */
 49      xlong_t mem_limit;
 50      /* maximal amount of memory (in bytes) available for dynamic
 51         allocation */
 52      LIBMEM *mem_ptr;
 53      /* pointer to the linked list of allocated memory blocks */
 54      int mem_count;
 55      /* total number of currently allocated memory blocks */
 56      int mem_cpeak;
 57      /* peak value of mem_count */
 58      xlong_t mem_total;
 59      /* total amount of currently allocated memory (in bytes; is the
 60         sum of the size field over all memory block descriptors) */
 61      xlong_t mem_tpeak;
 62      /* peak value of mem_total */
 63      /*--------------------------------------------------------------*/
 64      /* terminal output */
 65      int term_out;
 66      /* flag to enable/disable terminal output */
 67      int (*term_hook)(void *info, const char *s);
 68      /* user-defined routine to intercept terminal output */
 69      void *term_info;
 70      /* transit pointer passed to the routine term_hook */
 71      /*--------------------------------------------------------------*/
 72      /* input/output streams */
 73      char err_msg[1000+1];
 74      XFILE *file_ptr;
 75      /* pointer to the linked list of active stream descriptors */
 76      void *log_file; /* FILE *log_file; */
 77      /* output stream used to hardcopy all terminal output; NULL means
 78         no hardcopying */
 79      const char *err_file;
 80      int err_line;
 81      /*--------------------------------------------------------------*/
 82      /* standard time */
 83      xlong_t t_init, t_last;
 84      char c_init[sizeof(double)]; /* clock_t c_init; */
 85      /*--------------------------------------------------------------*/
 86      /* shared libraries */
 87      void *h_odbc;  /* handle to ODBC shared library */
 88      void *h_mysql; /* handle to MySQL shared library */
 89};
 90
 91#define LIB_MEM_FLAG 0x20101960
 92/* memory block descriptor flag */
 93
 94struct LIBMEM
 95{     /* memory block descriptor */
 96      int flag;
 97      /* descriptor flag */
 98      int size;
 99      /* size of block (in bytes, including descriptor) */
100      LIBMEM *prev;
101      /* pointer to previous memory block descriptor */
102      LIBMEM *next;
103      /* pointer to next memory block descriptor */
104};
105
106struct XFILE
107{     /* input/output stream descriptor */
108      int type;
109      /* stream handle type: */
110#define FH_FILE   0x11  /* FILE   */
111#define FH_ZLIB   0x22  /* gzFile */
112      void *fh;
113      /* pointer to stream handle */
114      XFILE *prev;
115      /* pointer to previous stream descriptor */
116      XFILE *next;
117      /* pointer to next stream descriptor */
118};
119
120#define XEOF (-1)
121
122#define bigmul _glp_lib_bigmul
123void bigmul(int n, int m, unsigned short x[], unsigned short y[]);
124/* multiply unsigned integer numbers of arbitrary precision */
125
126#define bigdiv _glp_lib_bigdiv
127void bigdiv(int n, int m, unsigned short x[], unsigned short y[]);
128/* divide unsigned integer numbers of arbitrary precision */
129
130#define xlset _glp_lib_xlset
131xlong_t xlset(int x);
132/* expand integer to long integer */
133
134#define xlneg _glp_lib_xlneg
135xlong_t xlneg(xlong_t x);
136/* negate long integer */
137
138#define xladd _glp_lib_xladd
139xlong_t xladd(xlong_t x, xlong_t y);
140/* add long integers */
141
142#define xlsub _glp_lib_xlsub
143xlong_t xlsub(xlong_t x, xlong_t y);
144/* subtract long integers */
145
146#define xlcmp _glp_lib_xlcmp
147int xlcmp(xlong_t x, xlong_t y);
148/* compare long integers */
149
150#define xlmul _glp_lib_xlmul
151xlong_t xlmul(xlong_t x, xlong_t y);
152/* multiply long integers */
153
154#define xldiv _glp_lib_xldiv
155xldiv_t xldiv(xlong_t x, xlong_t y);
156/* divide long integers */
157
158#define xltod _glp_lib_xltod
159double xltod(xlong_t x);
160/* convert long integer to double */
161
162#define xltoa _glp_lib_xltoa
163char *xltoa(xlong_t x, char *s);
164/* convert long integer to character string */
165
166#define lib_set_ptr _glp_lib_set_ptr
167void lib_set_ptr(void *ptr);
168/* store global pointer in TLS */
169
170#define lib_get_ptr _glp_lib_get_ptr
171void *lib_get_ptr(void);
172/* retrieve global pointer from TLS */
173
174#define lib_init_env _glp_lib_init_env
175int lib_init_env(void);
176/* initialize library environment */
177
178#define lib_link_env _glp_lib_link_env
179LIBENV *lib_link_env(void);
180/* retrieve pointer to library environment block */
181
182#define lib_version _glp_lib_version
183const char *lib_version(void);
184/* determine library version */
185
186#define lib_free_env _glp_lib_free_env
187int lib_free_env(void);
188/* free library environment */
189
190#define xgetc _glp_lib_xgetc
191int xgetc(void);
192/* read character from the terminal */
193
194#define xputc _glp_lib_xputc
195void xputc(int c);
196/* write character to the terminal */
197
198#define xprintf _glp_lib_xprintf
199void xprintf(const char *fmt, ...);
200/* write formatted output to the terminal */
201
202#define xvprintf _glp_lib_xvprintf
203void xvprintf(const char *fmt, va_list arg);
204/* write formatted output to the terminal */
205
206#define lib_term_hook _glp_lib_term_hook
207void lib_term_hook(int (*func)(void *info, const char *s), void *info);
208/* install hook to intercept terminal output */
209
210#define lib_print_hook _glp_lib_print_hook
211void lib_print_hook(int (*func)(void *info, char *buf), void *info);
212/* (obsolete) */
213
214#if 0
215#define xerror _glp_lib_xerror
216void xerror(const char *fmt, ...);
217/* display error message and terminate execution */
218#else
219#define xerror lib_xerror1(__FILE__, __LINE__)
220
221typedef void (*xerror_t)(const char *fmt, ...);
222
223#define lib_xerror1 _glp_lib_xerror1
224xerror_t lib_xerror1(const char *file, int line);
225
226#define lib_xerror2 _glp_lib_xerror2
227void lib_xerror2(const char *fmt, ...);
228#endif
229
230#define lib_fault_hook _glp_lib_fault_hook
231void lib_fault_hook(int (*func)(void *info, char *buf), void *info);
232/* (obsolete) */
233
234#define xassert(expr) \
235      ((void)((expr) || (lib_xassert(#expr, __FILE__, __LINE__), 1)))
236
237#define lib_xassert _glp_lib_xassert
238void lib_xassert(const char *expr, const char *file, int line);
239/* check for logical condition */
240
241#define xmalloc _glp_lib_xmalloc
242void *xmalloc(int size);
243/* allocate memory block */
244
245#define xcalloc _glp_lib_xcalloc
246void *xcalloc(int n, int size);
247/* allocate memory block */
248
249#define xfree _glp_lib_xfree
250void xfree(void *ptr);
251/* free memory block */
252
253#define lib_mem_limit _glp_lib_mem_limit
254void lib_mem_limit(xlong_t limit);
255/* set memory allocation limit */
256
257#define lib_mem_usage _glp_lib_mem_usage
258void lib_mem_usage(int *count, int *cpeak, xlong_t *total,
259      xlong_t *tpeak);
260/* get memory usage information */
261
262#define lib_err_msg _glp_lib_err_msg
263void lib_err_msg(const char *msg);
264
265#define xerrmsg _glp_lib_xerrmsg
266const char *xerrmsg(void);
267
268#define xfopen _glp_lib_xfopen
269XFILE *xfopen(const char *fname, const char *mode);
270
271#define xferror _glp_lib_xferror
272int xferror(XFILE *file);
273
274#define xfeof _glp_lib_xfeof
275int xfeof(XFILE *file);
276
277#define xfgetc _glp_lib_xfgetc
278int xfgetc(XFILE *file);
279
280#define xfputc _glp_lib_xfputc
281int xfputc(int c, XFILE *file);
282
283#define xfflush _glp_lib_xfflush
284int xfflush(XFILE *fp);
285
286#define xfclose _glp_lib_xfclose
287int xfclose(XFILE *file);
288
289#define lib_doprnt _glp_lib_doprnt
290int lib_doprnt(int (*func)(void *info, int c), void *info, const char
291      *fmt, va_list arg);
292/* perform formatted output (basic routine) */
293
294#define xfprintf _glp_lib_xfprintf
295int xfprintf(XFILE *file, const char *fmt, ...);
296
297#define lib_open_log _glp_lib_open_log
298int lib_open_log(const char *fname);
299/* open hardcopy file */
300
301#define lib_close_log _glp_lib_close_log
302int lib_close_log(void);
303/* close hardcopy file */
304
305#if 0
306#define xtime1 _glp_lib_xtime1
307glp_ulong xtime1(void);
308/* determine the current universal time */
309#endif
310
311#if 0
312#define xdifftime1 _glp_lib_xdifftime1
313double xdifftime1(glp_ulong t1, glp_ulong t0);
314/* compute the difference between two time values */
315#endif
316
317#define xtime _glp_lib_xtime
318xlong_t xtime(void);
319/* determine the current universal time */
320
321#define xdifftime _glp_lib_xdifftime
322double xdifftime(xlong_t t1, xlong_t t0);
323
324#define str2int _glp_lib_str2int
325int str2int(const char *str, int *val);
326/* convert character string to value of int type */
327
328#define str2num _glp_lib_str2num
329int str2num(const char *str, double *val);
330/* convert character string to value of double type */
331
332#define strspx _glp_lib_strspx
333char *strspx(char *str);
334/* remove all spaces from character string */
335
336#define strtrim _glp_lib_strtrim
337char *strtrim(char *str);
338/* remove trailing spaces from character string */
339
340#define strrev _glp_lib_strrev
341char *strrev(char *s);
342/* reverse character string */
343
344#define gcd _glp_lib_gcd
345int gcd(int x, int y);
346/* compute greatest common divisor of two integers */
347
348#define gcdn _glp_lib_gcdn
349int gcdn(int n, int x[]);
350/* compute greatest common divisor of n integers */
351
352#define round2n _glp_lib_round2n
353double round2n(double x);
354/* round floating-point number to nearest power of two */
355
356#define fp2rat _glp_lib_fp2rat
357int fp2rat(double x, double eps, double *p, double *q);
358/* convert floating-point number to rational number */
359
360#define jday _glp_lib_jday
361int jday(int d, int m, int y);
362/* convert calendar date to Julian day number */
363
364#define jdate _glp_lib_jdate
365int jdate(int j, int *d, int *m, int *y);
366/* convert Julian day number to calendar date */
367
368#define xdlopen _glp_xdlopen
369void *xdlopen(const char *module);
370
371#define xdlsym _glp_xdlsym
372void *xdlsym(void *h, const char *symbol);
373
374#define xdlclose _glp_xdlclose
375void xdlclose(void *h);
376
377#endif
378
379/* eof */