1
/* @(#)osmessage.c 19.1 (ES0-DMD) 02/25/03 13:56:13 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
.IDENTIFICATION osmessage
33
.AUTHOR Francois Ochsenbein [ESO-IPG]
35
.VERSION 1.0 08-Oct-1987: Creation
36
.VERSION 1.1 19-Jan-1988: Added external pointer to be used
37
as message when oserror = -1.
38
.KEYWORDS System error messages
39
.ENVIRONMENT VAX/VMS Version
40
.COMMENTS The ``message'' list can be generated with
41
a program listed below as a comment. The following externals
45
\item oserror ({\em int}), system-independant error number
46
\item vmserror ({\em int}), VMS error code (on VMS only)
47
\item oserrmsg ({\em char *}), pointer to a text string to be used if
48
oserror has the value $-1$.
52
----------------------------------------------------------------------------*/
57
#define dsc$w_length len
58
#define dsc$a_pointer s
59
#include <descrip.h> /* System */
60
MID_GLOBAL int vmserror = 0; /* VMS-specific error code */
61
#define LINESIZE 120 /* Maximum size of message */
63
MID_STATIC char msg_s[LINESIZE] = "?";
64
static short int msglen; /* Returned length from SYS$GETMSG */
65
MID_STATIC struct dsc$descriptor_s msg =
66
{ sizeof(msg_s)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, msg_s };
67
MID_RSTATIC char *sys_errlist[] = { "?"
68
,"not owner" /* EPERM */
69
,"no such file or directory" /* ENOENT */
70
,"no such process" /* ESRCH */
71
,"interrupted system call" /* EINTR */
72
,"i/o error" /* EIO */
73
,"no such device or address" /* ENXIO */
74
,"arg list too long" /* E2BIG */
75
,"exec format error" /* ENOEXEC */
76
,"bad file number" /* EBADF */
77
,"no children" /* ECHILD */
78
,"no more processes" /* EAGAIN */
79
,"not enough core" /* ENOMEM */
80
,"permission denied" /* EACCES */
81
,"bad address" /* EFAULT */
82
,"block device required" /* ENOTBLK */
83
,"mount device busy" /* EBUSY */
84
,"file exists" /* EEXIST */
85
,"cross-device link" /* EXDEV */
86
,"no such device" /* ENODEV */
87
,"not a directory" /* ENOTDIR */
88
,"is a directory" /* EISDIR */
89
,"invalid argument" /* EINVAL */
90
,"file table overflow" /* ENFILE */
91
,"too many open files" /* EMFILE */
92
,"not a typewriter" /* ENOTTY */
93
,"text file busy" /* ETXTBSY */
94
,"file too large" /* EFBIG */
95
,"no space left on device" /* ENOSPC */
96
,"illegal seek" /* ESPIPE */
97
,"read-only file system" /* EROFS */
98
,"too many links" /* EMLINK */
99
,"broken pipe" /* EPIPE */
100
,"math argument" /* EDOM */
101
,"result too large" /* ERANGE */
102
,"I/O operation would block channel" /* EWOULDBLOCK */
104
MID_STATIC int sys_nerr = ITEMS(sys_errlist);
106
MID_GLOBAL int oserror = 0; /* System error code */
107
MID_GLOBAL char *oserrmsg = NULL_PTR(char); /* If oserror == -1 */
109
/*==========================================================================*/
112
.PURPOSE Provide a text explaining the error.
113
.RETURNS Pointer to the relevant message. VMS messages are included.
119
if (oserror < 0 ) p = oserrmsg;
121
{ if (oserror >= sys_nerr) oserror = 0;
122
p = sys_errlist[oserror];
124
for (q = msg_s; *p != EOS; p++, q++) *q = *p;
127
msg.len= sizeof(msg_s) - 3 - (q-msg_s);
128
if (vmserror) SYS$GETMSG(vmserror,&msglen,&msg,15,0);
141
/* ------------- The following is the program to retrieve error messages */
150
int fin, fout, n, n0, i, j, i0;
151
static char line[200];
154
fin = osdopen("SYS$LIBRARY:errno.h", READ);
156
fin = osdopen("/usr/include/errno.h", READ);
158
fout = osdopen("errno.lis", WRITE);
159
if (fout < 0) printf("****Bad Output File***");
161
osdputs(fout, "static char *sys_errlist[] = { \"?\"");
163
while (osdgets(fin, line, sizeof(line)) > 0)
164
{ if (line[0] != '#') continue;
165
if (line[1] != 'd') continue;
167
while(isgraph(line[i])) i++;
168
while(isspace(line[i])) i++;
170
while(isgraph(line[i])) i++;
171
while(isspace(line[i])) i++;
173
if (n != n0) { printf("Bad number in: %s\n", line);
177
while(line[i] != '/') i++;
180
while(isspace(line[i])) i++;
181
j = strlen(line) - 3;
182
while(isspace(line[j])) j--;
192
while((j-i) < 48) line[++j] = ' ';
196
while(isgraph(line[i0])) line[++j] = line[i0++];
201
osdputs(fout, &line[i]);
204
osdputs(fout, "\t};");