miriad 4.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +103 -0
- data/Rakefile +82 -0
- data/ext/bug.c +341 -0
- data/ext/dio.c +317 -0
- data/ext/extconf.rb +49 -0
- data/ext/headio.c +835 -0
- data/ext/hio.c +1515 -0
- data/ext/hio.h +48 -0
- data/ext/interface.c +74 -0
- data/ext/io.h +56 -0
- data/ext/key.c +934 -0
- data/ext/maskio.c +398 -0
- data/ext/maxdimc.h.in +9 -0
- data/ext/miriad.h +371 -0
- data/ext/miriad.i +464 -0
- data/ext/miriad_ruby.c +602 -0
- data/ext/miriad_ruby.i +443 -0
- data/ext/miriad_wrap.c +4210 -0
- data/ext/narray_ruby.swg +59 -0
- data/ext/pack.c +639 -0
- data/ext/scrio.c +132 -0
- data/ext/sysdep.h +185 -0
- data/ext/uvio.c +4934 -0
- data/ext/xyio.c +476 -0
- data/ext/xyzio.c +2020 -0
- data/lib/miriad.rb +564 -0
- metadata +93 -0
data/README
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--
|
2
|
+
|
3
|
+
$Id: README 903 2008-04-17 23:05:44Z davidm $
|
4
|
+
|
5
|
+
This file includes an RDoc hack so that links can be made to open up into a new
|
6
|
+
frame rather then the current frame.
|
7
|
+
|
8
|
+
The "trick" is to append ``"target="_top'' to the URL.
|
9
|
+
|
10
|
+
++
|
11
|
+
|
12
|
+
= MIRIAD-Ruby
|
13
|
+
|
14
|
+
== Introduction
|
15
|
+
|
16
|
+
The MIRIAD-Ruby package...
|
17
|
+
|
18
|
+
1. Makes MIRIAD datasets accessible from Ruby by wrapping the {MIRIAD
|
19
|
+
UVIO}[link:classes/Miriad/Uvio.html] routines.
|
20
|
+
|
21
|
+
2. Makes Ruby usable with MIRIAD datasets by adding convenience, utility, and
|
22
|
+
astronomy related methods to Ruby classes.
|
23
|
+
|
24
|
+
== Installation
|
25
|
+
|
26
|
+
MIRIAD-Ruby can be installed in three easy steps.
|
27
|
+
|
28
|
+
1. Install Ruby. See the {Ruby Download Page
|
29
|
+
}[http://www.ruby-lang.org/en/downloads/"target="_top] for instructions.
|
30
|
+
|
31
|
+
2. Install RubyGems (for Ruby < 1.9.0) See the {RubyGems web site
|
32
|
+
}[http://www.rubygems.org/"target="_top] for instructions.
|
33
|
+
|
34
|
+
3. Install MIRIAD-Ruby by running...
|
35
|
+
|
36
|
+
<tt>gem install miriad</tt>
|
37
|
+
|
38
|
+
or
|
39
|
+
|
40
|
+
<tt>sudo gem install miriad</tt>
|
41
|
+
|
42
|
+
== Documentation
|
43
|
+
|
44
|
+
You are reading part of it!
|
45
|
+
|
46
|
+
=== On the web
|
47
|
+
|
48
|
+
The latest documentation is published on the {MIRIAD-Ruby Home
|
49
|
+
Page}[http://miriad.rubyforge.org/"target="_top]
|
50
|
+
|
51
|
+
=== At your local site
|
52
|
+
|
53
|
+
The MIRIAD-Ruby gem contains full documentation, which will be installed along
|
54
|
+
with the gem (unless you specified <tt>--no-rdoc</tt> or <tt>--no-ri</tt>, but
|
55
|
+
why would you do that?).
|
56
|
+
|
57
|
+
To view the local HTML documentation generated from the RDoc comments:
|
58
|
+
|
59
|
+
1. Run <tt>gem server</tt>.
|
60
|
+
|
61
|
+
2. Point your browser at <tt>http</tt><tt>://localhost:8808/</tt>
|
62
|
+
|
63
|
+
3. Find the +miriad+ entry.
|
64
|
+
|
65
|
+
4. Click on the [rdoc] link.
|
66
|
+
|
67
|
+
To view the local +ri+ documentation (kind if like +man+ or +info+ for Ruby),
|
68
|
+
just run <tt>ri <em>class_or_method</em></tt>. For example, to find out about
|
69
|
+
all the ways to call <tt>read()</tt>, type <tt>ri Miriad::Uvio#read</tt>.
|
70
|
+
|
71
|
+
== Further Reading
|
72
|
+
|
73
|
+
Additional information about MIRIAD-Ruby can be found at:
|
74
|
+
|
75
|
+
* {The MIRIAD-Ruby Rubyforge Project Page
|
76
|
+
}[http://rubyforge.org/projects/miriad/"target="_top]
|
77
|
+
|
78
|
+
Additional information about MIRIAD can be found at:
|
79
|
+
|
80
|
+
* {The Australia Compact Array web page
|
81
|
+
}[http://www.atnf.csiro.au/computing/software/miriad/"target="_top]
|
82
|
+
|
83
|
+
* {The MIRIAD Software Page at the University of Maryland
|
84
|
+
}[http://bima.astro.umd.edu/miriad/"target="_top]
|
85
|
+
|
86
|
+
== Acknowledgements
|
87
|
+
|
88
|
+
The MIRAD-Ruby package is distributed with a snapshot of MIRIAD's lower level
|
89
|
+
I/O routines writtin in ANSI C. Most of the MIRIAD functionality provided by
|
90
|
+
MIRIAD-Ruby is actually performed by this C code, which MIRIAD-Ruby wraps and
|
91
|
+
exposes to Ruby.
|
92
|
+
|
93
|
+
Much of the documentation for the {Miriad::Uvio}[link:classes/Miriad/Uvio.html]
|
94
|
+
routines was transcribed into Rdoc format from {The _Miriad_ Programmer's Guide
|
95
|
+
}[http://www.atnf.csiro.au/computing/software/miriad/progguide/progguide.html"target="_top].
|
96
|
+
|
97
|
+
Authors too numerous to list (and too likely to prefer anonymity) have
|
98
|
+
contributed to both the C code and the documentation. If you are one of them
|
99
|
+
and would like to be mentioned here, please file a bug report on the
|
100
|
+
MIRIAD-Ruby Rubyforge project page.
|
101
|
+
|
102
|
+
--
|
103
|
+
# vim: set expandtab ts=2 sw=2 smarttab syntax=ruby autoindent fo+=taroq2 :
|
data/Rakefile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
def run_swig
|
5
|
+
sh("swig -ruby -autorename -o ext/miriad_wrap.c ext/miriad.i")
|
6
|
+
end
|
7
|
+
|
8
|
+
# The SWIG-generated wrapper must exist before creating the gemspec
|
9
|
+
# otherwise it will not be included in the gem!
|
10
|
+
run_swig unless test ?e, 'ext/miriad_wrap.c'
|
11
|
+
|
12
|
+
spec = Gem::Specification.new do |s|
|
13
|
+
# Basics
|
14
|
+
s.name = 'miriad'
|
15
|
+
s.version = '4.1.0.0'
|
16
|
+
s.summary = 'Ruby interface to MIRIAD'
|
17
|
+
s.description = <<-EOS
|
18
|
+
The MIRIAD-Ruby package...
|
19
|
+
|
20
|
+
1. Makes MIRIAD datasets accessible from Ruby by wrapping
|
21
|
+
the MIRIAD UVIO routines.
|
22
|
+
|
23
|
+
2. Makes Ruby usable with MIRIAD datasets by adding convenience,
|
24
|
+
utility, and astronomy related methods to Ruby classes.
|
25
|
+
EOS
|
26
|
+
|
27
|
+
#s.platform = Gem::Platform::Ruby
|
28
|
+
s.required_ruby_version = '>= 1.8.6'
|
29
|
+
#s.requirements << 'a prerequisite'
|
30
|
+
s.add_dependency('narray', '>= 0.5.9')
|
31
|
+
|
32
|
+
# About
|
33
|
+
s.authors = 'David MacMahon'
|
34
|
+
s.email = 'davidm@astro.berkeley.edu'
|
35
|
+
s.homepage = 'http://miriad.rubyforge.org/'
|
36
|
+
s.rubyforge_project = 'miriad'
|
37
|
+
|
38
|
+
# Files, Libraries, and Extensions
|
39
|
+
s.files = FileList[
|
40
|
+
'README',
|
41
|
+
'Rakefile',
|
42
|
+
'lib/miriad.rb',
|
43
|
+
'ext/*.c',
|
44
|
+
'ext/*.h',
|
45
|
+
'ext/*.i',
|
46
|
+
'ext/*.in',
|
47
|
+
'ext/extconf.rb',
|
48
|
+
'ext/*.swg'
|
49
|
+
].to_a
|
50
|
+
s.files.delete 'ext/maxdimc.h'
|
51
|
+
s.require_paths = ['lib', 'ext']
|
52
|
+
#s.autorequire = nil
|
53
|
+
#s.bindir = 'bin'
|
54
|
+
#s.executables = []
|
55
|
+
#s.default_executable = nil
|
56
|
+
|
57
|
+
# C compilation
|
58
|
+
s.extensions << 'ext/extconf.rb'
|
59
|
+
|
60
|
+
# Documentation
|
61
|
+
s.rdoc_options = ['-x', 'ext/.*.c', '-m', 'README', '-t', "MIRIAD-Ruby Documentation"]
|
62
|
+
s.has_rdoc = true
|
63
|
+
s.extra_rdoc_files = %w[README ext/miriad_ruby.c]
|
64
|
+
|
65
|
+
# Testing TODO
|
66
|
+
#s.test_files = []
|
67
|
+
end
|
68
|
+
|
69
|
+
file "ext/miriad_wrap.c" => %w[ext/miriad.i ext/miriad_ruby.i ext/narray_ruby.swg] do |t|
|
70
|
+
sh("swig -ruby -autorename -o #{t.name} #{t.prerequisites[0]}")
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Run SWIG to generate the wrapper code."
|
74
|
+
task :swig => "ext/miriad_wrap.c"
|
75
|
+
|
76
|
+
task "pkg" => :swig
|
77
|
+
|
78
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
79
|
+
task pkg.package_dir_path => :swig
|
80
|
+
pkg.need_zip = true
|
81
|
+
pkg.need_tar = true
|
82
|
+
end
|
data/ext/bug.c
ADDED
@@ -0,0 +1,341 @@
|
|
1
|
+
/************************************************************************/
|
2
|
+
/* */
|
3
|
+
/* This handles errors and can abort your program. */
|
4
|
+
/* */
|
5
|
+
/* History: */
|
6
|
+
/* rjs,mjs ???? Very mixed history. Created, destroyed, rewritten.*/
|
7
|
+
/* rjs 26aug93 Call habort_c. */
|
8
|
+
/* rjs 14jul98 Add a caste operation in errmsg_c, to attempt */
|
9
|
+
/* to appease some compilers. */
|
10
|
+
/* pjt 23sep01 darwin */
|
11
|
+
/* pjt 4dec01 bypass fatal errors (for alien clients) if req'd */
|
12
|
+
/* through the new bugrecover_c() routine */
|
13
|
+
/* pjt 17jun02 prototypes for MIR4 */
|
14
|
+
/* pjt/ram 5dec03 using strerror() for unix */
|
15
|
+
/* pjt 1jan05 bugv_c: finally, a real stdargs version!!! */
|
16
|
+
/* though cannot be exported to Fortran */
|
17
|
+
/* pjt 26mar07 bugmessage_c: retrieve last fatal bug message */
|
18
|
+
/* pjt 27mar07 bugseverity_c: also overhauled bug recovery */
|
19
|
+
/* and removed VMS specific code */
|
20
|
+
/* pjt 17may07 removed old-non ANSI declaration */
|
21
|
+
/* pjt 5dec07 add Name to bug output - why took us so long? */
|
22
|
+
/* pkgw 6mar08 declare Name as static to prevent symbol clashes */
|
23
|
+
/************************************************************************/
|
24
|
+
|
25
|
+
#include <stdio.h>
|
26
|
+
#include <stdlib.h>
|
27
|
+
#include <string.h>
|
28
|
+
#include <stdarg.h>
|
29
|
+
#include "miriad.h"
|
30
|
+
|
31
|
+
/*
|
32
|
+
* Added by MIRIAD-Ruby
|
33
|
+
*/
|
34
|
+
#ifdef MIRIAD_RUBY
|
35
|
+
#include "ruby.h"
|
36
|
+
|
37
|
+
extern VALUE mirlib_eMirlibError;
|
38
|
+
|
39
|
+
#define fprintf(io,fmt,...) \
|
40
|
+
do { \
|
41
|
+
switch(s) { \
|
42
|
+
case 'i': case 'I': \
|
43
|
+
case 'w': case 'W': \
|
44
|
+
fprintf(io,fmt,__VA_ARGS__); \
|
45
|
+
break; \
|
46
|
+
default: \
|
47
|
+
rb_raise(mirlib_eMirlibError,fmt,__VA_ARGS__); \
|
48
|
+
} \
|
49
|
+
} while(0)
|
50
|
+
|
51
|
+
#define exit(never)
|
52
|
+
#endif /* MIRIAD_RUBY */
|
53
|
+
|
54
|
+
static char *errmsg_c(int n);
|
55
|
+
static int handle_bug_cleanup(int d, char s, Const char *m);
|
56
|
+
|
57
|
+
static char *Name = NULL; /* a slot to store the program name */
|
58
|
+
int reentrant=0; /* keep track of state */
|
59
|
+
|
60
|
+
typedef void (*proc)(void); /* helper definition for function pointers */
|
61
|
+
|
62
|
+
static proc bug_cleanup=NULL; /* external bug handler, if any */
|
63
|
+
static char *bug_message=0; /* last message */
|
64
|
+
static char bug_severity=0; /* last severity level (i,w,e or f) */
|
65
|
+
|
66
|
+
|
67
|
+
#define MAXMSG 256
|
68
|
+
static char msg[MAXMSG]; /* formatted message for bugv_c() */
|
69
|
+
|
70
|
+
|
71
|
+
/************************************************************************/
|
72
|
+
char *bugmessage_c(void)
|
73
|
+
/** bugmessage_c -- return last fatal error message string */
|
74
|
+
/*& pjt */
|
75
|
+
/*: error-handling */
|
76
|
+
/*+
|
77
|
+
This routine does not have a FORTRAN counterpart, as it is normally
|
78
|
+
only called by C clients who have set their own error handler if
|
79
|
+
for some reason they don't like the MIRIAD one (e.g. C++ or java
|
80
|
+
exceptions, or NEMO's error handler. This way the bugrecover handler
|
81
|
+
can call this routine to retrieve the last fatal error message.
|
82
|
+
|
83
|
+
bugrecover_c(my_handler);
|
84
|
+
|
85
|
+
void my_handler(void) {
|
86
|
+
char *m = bugmessage_c();
|
87
|
+
printf("RECOVERED: %s\n",m);
|
88
|
+
}
|
89
|
+
.. */
|
90
|
+
/*-- */
|
91
|
+
/*----------------------------------------------------------------------*/
|
92
|
+
{
|
93
|
+
return bug_message;
|
94
|
+
}
|
95
|
+
|
96
|
+
/************************************************************************/
|
97
|
+
char bugseverity_c(void)
|
98
|
+
/** bugseverity_c -- return last severity level */
|
99
|
+
/*& pjt */
|
100
|
+
/*: error-handling */
|
101
|
+
/*+
|
102
|
+
This routine does not have a FORTRAN counterpart, as it is normally
|
103
|
+
only called by C clients who have set their own error handler if
|
104
|
+
for some reason they don't like the MIRIAD one (e.g. C++ or java
|
105
|
+
exceptions, or NEMO's error handler. This way the bugrecover handler
|
106
|
+
can call this routine to retrieve the last severity level
|
107
|
+
|
108
|
+
bugrecover_c(my_handler);
|
109
|
+
|
110
|
+
void my_handler(void) {
|
111
|
+
char s = bugseverity_c();
|
112
|
+
char *m = bugmessage_c();
|
113
|
+
printf("RECOVERED: (%c) %s\n",s,m);
|
114
|
+
if (s=='f') exit(1);
|
115
|
+
}
|
116
|
+
.. */
|
117
|
+
/*-- */
|
118
|
+
/*----------------------------------------------------------------------*/
|
119
|
+
{
|
120
|
+
return bug_severity;
|
121
|
+
}
|
122
|
+
|
123
|
+
/************************************************************************/
|
124
|
+
void bugrecover_c(void (*cl)(void))
|
125
|
+
/** bugrecover_c -- bypass fatal bug calls for alien clients */
|
126
|
+
/*& pjt */
|
127
|
+
/*: error-handling */
|
128
|
+
/*+
|
129
|
+
This routine does not have a FORTRAN counterpart, as it is normally
|
130
|
+
only called by C clients who need to set their own error handler if
|
131
|
+
for some reason they don't like the MIRIAD one (e.g. C++ or java
|
132
|
+
exceptions, or NEMO's error handler
|
133
|
+
Example of usage:
|
134
|
+
|
135
|
+
void my_handler(void) {
|
136
|
+
....
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
..
|
141
|
+
bugrecover_c(my_handler);
|
142
|
+
.. */
|
143
|
+
/*-- */
|
144
|
+
/*----------------------------------------------------------------------*/
|
145
|
+
{
|
146
|
+
bug_cleanup = cl;
|
147
|
+
if (bug_message) free(bug_message);
|
148
|
+
bug_message = strdup("no bug_message has been set yet");
|
149
|
+
}
|
150
|
+
|
151
|
+
/************************************************************************/
|
152
|
+
void buglabel_c(Const char *name)
|
153
|
+
/** buglabel -- Give the "program name" to be used as a label in messages. */
|
154
|
+
/*& pjt */
|
155
|
+
/*: error-handling */
|
156
|
+
/*+ FORTRAN call sequence:
|
157
|
+
subroutine buglabel(name)
|
158
|
+
|
159
|
+
implicit none
|
160
|
+
character name*(*)
|
161
|
+
|
162
|
+
Give the name that is to be used as a label in error messages. Usually
|
163
|
+
this is the program name and should be set by the user interface.
|
164
|
+
|
165
|
+
Input:
|
166
|
+
name The name to be given as a label in error messages. */
|
167
|
+
/*-- */
|
168
|
+
/*----------------------------------------------------------------------*/
|
169
|
+
{
|
170
|
+
if(Name != NULL)free(Name);
|
171
|
+
Name = malloc(strlen(name)+1);
|
172
|
+
strcpy(Name,name);
|
173
|
+
}
|
174
|
+
/************************************************************************/
|
175
|
+
void bug_c(char s,Const char *m)
|
176
|
+
/** bug -- Issue an error message, given by the caller. */
|
177
|
+
/*& pjt */
|
178
|
+
/*: error-handling */
|
179
|
+
/*+ FORTRAN call sequence:
|
180
|
+
subroutine bug(severity,message)
|
181
|
+
|
182
|
+
implicit none
|
183
|
+
character severity*1
|
184
|
+
character message*(*)
|
185
|
+
|
186
|
+
Output the error message given by the caller, and abort if needed.
|
187
|
+
|
188
|
+
Input:
|
189
|
+
severity Error severity. Can be one of 'i', 'w', 'e' or 'f'
|
190
|
+
for "informational", "warning", "error", or "fatal"
|
191
|
+
message The error message text. */
|
192
|
+
/*-- */
|
193
|
+
/*----------------------------------------------------------------------*/
|
194
|
+
{
|
195
|
+
char *p;
|
196
|
+
int doabort;
|
197
|
+
|
198
|
+
doabort = 0;
|
199
|
+
if (s == 'i' || s == 'I') p = "Informational";
|
200
|
+
else if (s == 'w' || s == 'W') p = "Warning";
|
201
|
+
else if (s == 'e' || s == 'E') p = "Error";
|
202
|
+
else {doabort = 1; p = "Fatal Error"; }
|
203
|
+
|
204
|
+
if (!bug_cleanup)
|
205
|
+
{
|
206
|
+
if ( Name == NULL )
|
207
|
+
buglabel_c("(NOT SET)");
|
208
|
+
fprintf(stderr,"### %s [%s]: %s\n",p,Name,m);
|
209
|
+
}
|
210
|
+
|
211
|
+
if(doabort){
|
212
|
+
reentrant = !reentrant;
|
213
|
+
if(reentrant)habort_c();
|
214
|
+
if (!handle_bug_cleanup(doabort,s,m))
|
215
|
+
exit(1);
|
216
|
+
} else
|
217
|
+
handle_bug_cleanup(doabort,s,m);
|
218
|
+
|
219
|
+
}
|
220
|
+
/************************************************************************/
|
221
|
+
void bugv_c(char s,Const char *m, ...)
|
222
|
+
/** bugv_c -- Issue a dynamic error message, given by the caller. */
|
223
|
+
/*& pjt */
|
224
|
+
/*: error-handling */
|
225
|
+
/*+ C call sequence:
|
226
|
+
bugv_c(severity,message,....)
|
227
|
+
|
228
|
+
Output the error message given by the caller, and abort if needed.
|
229
|
+
Note this routine has no counterpart in FORTRAN.
|
230
|
+
|
231
|
+
Input:
|
232
|
+
severity Error severity character.
|
233
|
+
Can be one of 'i', 'w', 'e' or 'f'
|
234
|
+
for "informational", "warning", "error", or "fatal"
|
235
|
+
message The error message string, can contain %-printf style
|
236
|
+
directives, as used by the following arguments.
|
237
|
+
... Optional argument, in the printf() style */
|
238
|
+
/*-- */
|
239
|
+
/*----------------------------------------------------------------------*/
|
240
|
+
{
|
241
|
+
va_list ap;
|
242
|
+
char *p;
|
243
|
+
int doabort,len;
|
244
|
+
|
245
|
+
doabort = 0;
|
246
|
+
if (s == 'i' || s == 'I') p = "Informational";
|
247
|
+
else if (s == 'w' || s == 'W') p = "Warning";
|
248
|
+
else if (s == 'e' || s == 'E') p = "Error";
|
249
|
+
else {doabort = 1; p = "Fatal Error"; }
|
250
|
+
|
251
|
+
va_start(ap,m);
|
252
|
+
|
253
|
+
if ( Name == NULL )
|
254
|
+
buglabel_c("(NOT SET)");
|
255
|
+
|
256
|
+
snprintf(msg,MAXMSG,"### %s [%s]: ",p,Name);
|
257
|
+
len = strlen(msg);
|
258
|
+
vsnprintf(&msg[len],MAXMSG-len,m,ap);
|
259
|
+
va_end(ap);
|
260
|
+
|
261
|
+
if (!bug_cleanup)
|
262
|
+
fprintf(stderr,"%s\n",msg);
|
263
|
+
|
264
|
+
if(doabort){
|
265
|
+
reentrant = !reentrant;
|
266
|
+
if(reentrant)habort_c();
|
267
|
+
if (!handle_bug_cleanup(doabort,s,&msg[len]))
|
268
|
+
exit(1);
|
269
|
+
} else
|
270
|
+
handle_bug_cleanup(doabort,s,&msg[len]);
|
271
|
+
|
272
|
+
}
|
273
|
+
|
274
|
+
/************************************************************************/
|
275
|
+
void bugno_c(char s,int n)
|
276
|
+
/** bugno -- Issue an error message, given a system error number. */
|
277
|
+
/*& pjt */
|
278
|
+
/*: error-handling */
|
279
|
+
/*+ FORTRAN call sequence:
|
280
|
+
subroutine bugno(severity,errno)
|
281
|
+
|
282
|
+
implicit none
|
283
|
+
character severity*1
|
284
|
+
integer errno
|
285
|
+
|
286
|
+
Output the error message associated with a particular error number.
|
287
|
+
|
288
|
+
Input:
|
289
|
+
severity Error severity. Can be one of 'i', 'w', 'e' or 'f'
|
290
|
+
for "informational", "warning", "error", or "fatal"
|
291
|
+
errno host error number. */
|
292
|
+
/*-- */
|
293
|
+
/*----------------------------------------------------------------------*/
|
294
|
+
{
|
295
|
+
if (n == -1)bug_c(s,"End of file detected");
|
296
|
+
else bug_c(s,errmsg_c(n));
|
297
|
+
}
|
298
|
+
/************************************************************************/
|
299
|
+
#define HAVE_STRERROR 1
|
300
|
+
static char *errmsg_c(int n)
|
301
|
+
/*
|
302
|
+
Return the error message associated with some error number.
|
303
|
+
------------------------------------------------------------------------*/
|
304
|
+
{
|
305
|
+
/* check for linux leaves this compat with old style build
|
306
|
+
* this should be removed in favor of HAVE_STRERROR once
|
307
|
+
* is only supported using autotools/configure
|
308
|
+
*/
|
309
|
+
#if defined(linux) || (defined(HAVE_STRERROR) && HAVE_STRERROR)
|
310
|
+
/* new POSIX.1 style, 20 years old now... (1988) */
|
311
|
+
return strerror(n);
|
312
|
+
#else
|
313
|
+
/* very old style code -- stdio.h is supposed to supply this */
|
314
|
+
# if 0
|
315
|
+
extern int sys_nerr;
|
316
|
+
extern char *sys_errlist[];
|
317
|
+
# endif
|
318
|
+
if(n > 0 && n <= sys_nerr)return((char *)sys_errlist[n]);
|
319
|
+
else {
|
320
|
+
sprintf(msg,"Unknown error with number %d detected.",n);
|
321
|
+
return msg;
|
322
|
+
}
|
323
|
+
#endif
|
324
|
+
}
|
325
|
+
/************************************************************************/
|
326
|
+
static int handle_bug_cleanup(int doabort, char s, Const char *m)
|
327
|
+
/*
|
328
|
+
Handle cleaning up a bug
|
329
|
+
------------------------------------------------------------------------*/
|
330
|
+
{
|
331
|
+
if (bug_cleanup) {
|
332
|
+
if (bug_message) free(bug_message);
|
333
|
+
bug_message = strdup(m); /* save last message */
|
334
|
+
bug_severity = s; /* save last severity */
|
335
|
+
(*bug_cleanup)(); /* call handler ; this may exit */
|
336
|
+
if (doabort) /* if it got here, handler didn't exit */
|
337
|
+
fprintf(stderr,"### handle_bug_cleanup: WARNING: code should not come here\n",0);
|
338
|
+
return 1;
|
339
|
+
}
|
340
|
+
return 0;
|
341
|
+
}
|