| 1 |
/*=========================================================================== |
| 2 |
Copyright (C) 1995-2009 European Southern Observatory (ESO) |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License as |
| 6 |
published by the Free Software Foundation; either version 2 of |
| 7 |
the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public |
| 15 |
License along with this program; if not, write to the Free |
| 16 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 17 |
MA 02139, USA. |
| 18 |
|
| 19 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 20 |
Internet e-mail: [email protected] |
| 21 |
Postal address: European Southern Observatory |
| 22 |
Data Management Division |
| 23 |
Karl-Schwarzschild-Strasse 2 |
| 24 |
D 85748 Garching bei Muenchen |
| 25 |
GERMANY |
| 26 |
===========================================================================*/ |
| 27 |
|
| 28 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 29 |
|
| 30 |
.TYPE Module |
| 31 |
.IDENTIFICATION osmessage |
| 32 |
.AUTHOR Francois Ochsenbein [ESO-IPG] |
| 33 |
.LANGUAGE C |
| 34 |
.KEYWORDS System error messages |
| 35 |
.ENVIRONMENT UNIX (BSD / SYSV) |
| 36 |
.COMMENTS The ``message'' list can be generated with |
| 37 |
a program listed below as a comment. The following externals |
| 38 |
are defined here: |
| 39 |
\begin{TeX} |
| 40 |
\begin{itemize} |
| 41 |
\item oserror ({\em int}), system-independant error number |
| 42 |
\item oserrmsg ({\em char *}), pointer to a text string to be used if |
| 43 |
oserror has the value $-1$. |
| 44 |
\end{itemize} |
| 45 |
\end{TeX} |
| 46 |
.VERSION 1.0 08-Oct-1987: Creation |
| 47 |
.VERSION 1.1 19-Jan-1988: Added external pointer to be used |
| 48 |
as message when oserror = -1. |
| 49 |
.VERSION |
| 50 |
|
| 51 |
090324 last modif |
| 52 |
----------------------------------------------------------------------------*/ |
| 53 |
|
| 54 |
#include <fcntl.h> |
| 55 |
#include <errno.h> |
| 56 |
#include <osdefos.h> |
| 57 |
#include <macrogen.h> |
| 58 |
#include <oserror.h> |
| 59 |
#include <proto_os.h> /* ANSI-C prototyping */ |
| 60 |
|
| 61 |
|
| 62 |
/*==========================================================================*/ |
| 63 |
char *osmsg() |
| 64 |
/*+++ |
| 65 |
.PURPOSE Provide a text explaining the error. |
| 66 |
.RETURNS Pointer to the relevant message. |
| 67 |
---*/ |
| 68 |
{ |
| 69 |
static char *p; |
| 70 |
|
| 71 |
if (oserror < 0 ) |
| 72 |
p = oserrmsg; |
| 73 |
else if (oserror) |
| 74 |
p = strerror(oserror); |
| 75 |
else |
| 76 |
p = ""; |
| 77 |
|
| 78 |
if (!p) p = "????"; |
| 79 |
|
| 80 |
return(p); |
| 81 |
} |