Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/runtime/c-libs/dl/dlerror.c
ViewVC logotype

Diff of /sml/trunk/src/runtime/c-libs/dl/dlerror.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 772, Thu Jan 4 15:36:41 2001 UTC revision 1573, Mon Aug 2 19:44:48 2004 UTC
# Line 3  Line 3 
3   * COPYRIGHT (c) 2000 by Lucent Technologies, Bell Laboratories   * COPYRIGHT (c) 2000 by Lucent Technologies, Bell Laboratories
4   */   */
5    
6    #ifndef OPSYS_WIN32
7  #include "ml-unixdep.h"  #include "ml-unixdep.h"
8    #endif
9  #include <dlfcn.h>  #include <dlfcn.h>
10  #include "ml-base.h"  #include "ml-base.h"
11  #include "ml-values.h"  #include "ml-values.h"
# Line 11  Line 13 
13  #include "ml-c.h"  #include "ml-c.h"
14  #include "cfun-proto-list.h"  #include "cfun-proto-list.h"
15    
16    #ifdef OPSYS_WIN32
17    
18    #include <stdio.h>
19    #include <stdlib.h>
20    #include <string.h>
21    
22    /* roll-your-own dlerror... */
23    static int dl_error_read = 0;
24    static char *dl_error = NULL;
25    
26    void dlerror_set (const char *fmt, const char *s)
27    {
28      if (dl_error != NULL)
29        free (dl_error);
30      dl_error = malloc (strlen (fmt) + strlen (s) + 1);
31      sprintf (dl_error, fmt, s);
32      dl_error_read = 0;
33    }
34    
35    char *dlerror (void)
36    {
37      if (dl_error)
38        if (dl_error_read) {
39          free (dl_error);
40          dl_error = NULL;
41        } else
42          dl_error_read = 1;
43    
44      return dl_error;
45    }
46    #endif
47    
48  /* _ml_P_Dynload_dlerror : unit -> string option  /* _ml_P_Dynload_dlerror : unit -> string option
49   *   *
50   * Extract error after unsuccessful dlopen/dlsym/dlclose.   * Extract error after unsuccessful dlopen/dlsym/dlclose.
51   */   */
52  ml_val_t _ml_U_Dynload_dlerror (ml_state_t *msp, ml_val_t ml_handle)  ml_val_t _ml_U_Dynload_dlerror (ml_state_t *msp, ml_val_t ml_handle)
53  {  {
54    char *e = dlerror ();    const char *e = dlerror ();
55    ml_val_t r, s;    ml_val_t r, s;
56    
57    if (e == NULL)    if (e == NULL)

Legend:
Removed from v.772  
changed lines
  Added in v.1573

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0