source: trunk/src/emx/src/libdl/dlerror.c@ 234

Last change on this file since 234 was 234, checked in by bird, 23 years ago

Initial coding (thought this might come in handy).

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/* $Id: dlerror.c 234 2003-05-26 09:28:55Z bird $ */
2/** @file
3 * dlclose - Close an dlopen'ed dynamic load library.
4 *
5 * Copyright (c) 2001-2003 knut st. osmundsen <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with This program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define INCL_BASE
27#include <os2.h>
28
29#include <stdio.h>
30#include <string.h>
31#include <dlfcn.h>
32
33#include "dlfcn_private.h"
34
35
36/**
37 * Returns the last error.
38 * The last error is reset by this call.
39 * @returns NULL if not error since last dlerror call.
40 * Error description string.
41 */
42const char *dlerror(void)
43{
44 if (dlfcn_ulLastError != NO_ERROR)
45 {
46 const char *pszOp = NULL;
47 char szTmpBuffer[DLFCN_MAX_ERROR_OBJ];
48
49 switch (dlfcn_enmLastOp)
50 {
51 case dlfcn_dlopen: pszOp = "dlopen"; break;
52 case dlfcn_dlclose: pszOp = "dlclose"; break;
53 case dlfcn_dlsym: pszOp = "dlerror"; break;
54 default: pszOp = "!internal error!"; break;
55 }
56
57 szTmpBuffer[0] = '\0';
58 if (dlfcn_enmLastOp == dlfcn_dlopen || dlfcn_enmLastOp == dlfcn_dlclose)
59 strncat(&szTmpBuffer[0], &dlfcn_szLastError[0], sizeof(szTmpBuffer));
60
61 if (szTmpBuffer[0] != '\0')
62 sprintf(&dlfcn_szLastError[0], "%s rc=%lu extra=%s", pszOp, dlfcn_ulLastError, &szTmpBuffer[0]);
63 else
64 sprintf(&dlfcn_szLastError[0], "%s rc=%lu", pszOp, dlfcn_ulLastError);
65
66 dlfcn_ulLastError = NO_ERROR;
67 dlfcn_enmLastOp = dlfcn_dlerror;
68 return &dlfcn_szLastError[0];
69 }
70
71 dlfcn_enmLastOp = dlfcn_dlerror;
72 return NULL;
73}
74
Note: See TracBrowser for help on using the repository browser.