2
* Grace - GRaphing, Advanced Computation and Exploration of data
4
* Home page: http://plasma-gate.weizmann.ac.il/Grace/
6
* Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7
* Copyright (c) 1996-2001 Grace Development Team
9
* Maintained by Evgeny Stambulchik <fnevgeny@plasma-gate.weizmann.ac.il>
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2 of the License, or
17
* (at your option) any later version.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33
#include <sys/types.h>
35
#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
37
#define MIN2(a, b) (((a) < (b)) ? a : b)
38
#define MAX2(a, b) (((a) > (b)) ? a : b)
39
#define MIN3(a, b, c) (((a) < (b)) ? MIN2(a, c) : MIN2(b, c))
40
#define MAX3(a, b, c) (((a) > (b)) ? MAX2(a, c) : MAX2(b, c))
42
#define yes_or_no(x) ((x)?"yes":"no")
43
#define on_or_off(x) ((x)?"on":"off")
44
#define true_or_false(x) ((x)?"true":"false")
45
#define w_or_v(x) ((x == COORD_WORLD)?"world":"view")
47
#define LFORMAT_TYPE_PLAIN 0
48
#define LFORMAT_TYPE_EXTENDED 1
50
#define XCFREE(ptr) xfree(ptr); ptr = NULL
52
#define PSTRING(s) ((s == NULL) ? "" : escapequotes(s))
54
void *xmalloc(size_t size);
55
void *xcalloc(size_t nmemb, size_t size);
56
void *xrealloc(void *ptr, size_t size);
57
void xfree(void *ptr);
59
void fswap(double *x, double *y);
60
void iswap(int *x, int *y);
61
int isoneof(int c, char *s);
62
int argmatch(char *s1, char *s2, int atleast);
63
void lowtoupper(char *s);
64
void convertchar(char *s);
66
double comp_area(int n, double *x, double *y);
67
double comp_perimeter(int n, double *x, double *y);
69
char *create_fstring(int form, int prec, double loc, int type);
70
char *escapequotes (char *s);
73
double mytrunc(double a);
77
void installSignal(void);
79
int bin_dump(char *value, int i, int pad);
80
unsigned char reversebits(unsigned char inword);
82
char *copy_string(char *dest, const char *src);
83
char *concat_strings(char *dest, const char *src);
84
int compare_strings(const char *s1, const char *s2);
86
char *get_grace_home(void);
87
void set_grace_home(const char *dir);
89
char *get_help_viewer(void);
90
void set_help_viewer(const char *dir);
92
char *get_print_cmd(void);
93
void set_print_cmd(const char *cmd);
95
char *get_editor(void);
96
void set_editor(const char *cmd);
98
void set_docname(const char *s);
99
char *get_docname(void);
100
char *get_docbname(void);
102
void errmsg(char *msg);
103
void echomsg(char *msg);
104
void stufftext(char *msg);
106
int yesnoterm(char *msg);
107
int yesno(char *msg, char *s1, char *s2, char *help_anchor);
109
char *mybasename(const char *s);
111
void expand_tilde(char *buf);
112
int set_workingdir(const char *wd);
113
char *get_workingdir(void);
115
void init_username(void);
116
char *get_username(void);
118
void init_userhome(void);
119
char *get_userhome(void);
121
void update_app_title(void);
123
void set_dirtystate(void);
124
void clear_dirtystate(void);
125
void lock_dirtystate(int flag);
126
int is_dirtystate(void);
128
int system_wrap(const char *string);
129
void msleep_wrap(unsigned int msec);
131
int init_locale(void);
132
void set_locale_num(int flag);
134
long bi_version_id(void);
135
char *bi_version_string(void);
136
char *bi_system(void);
140
char *bi_gui_xbae(void);
142
char *bi_ccompiler(void);
143
char *bi_t1lib(void);
145
char *bi_pnglib(void);
148
char *bi_libjpeg(void);
151
char *bi_libpdf(void);
156
void set_debuglevel(int level);
157
int get_debuglevel(void);
160
#endif /* __UTILS_H_*/