include/SDL_loadso.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 13 Feb 2014 11:05:24 -0800
changeset 8210 581caa876b2e
parent 8149 681eb46b8ac4
child 8215 54555ad9342c
permissions -rw-r--r--
Added SDL_GetLoadedModule to do the equivalent of GetModuleHandle/dlload(NOLOAD)

CR: Jorgen
slouken@648
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@648
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@648
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@648
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@648
    20
*/
slouken@648
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_loadso.h
slouken@1895
    24
 *
slouken@3407
    25
 *  System dependent library loading routines
slouken@1895
    26
 *
slouken@7191
    27
 *  Some things to keep in mind:
slouken@3407
    28
 *  \li These functions only work on C function names.  Other languages may
slouken@3407
    29
 *      have name mangling and intrinsic language support that varies from
slouken@3407
    30
 *      compiler to compiler.
slouken@3407
    31
 *  \li Make sure you declare your function pointers with the same calling
slouken@3407
    32
 *      convention as the actual library function.  Your code will crash
slouken@3407
    33
 *      mysteriously if you do not do this.
slouken@3407
    34
 *  \li Avoid namespace collisions.  If you load a symbol from the library,
slouken@3407
    35
 *      it is not defined whether or not it goes into the global symbol
slouken@3407
    36
 *      namespace for the application.  If it does and it conflicts with
slouken@3407
    37
 *      symbols in your code or other shared libraries, you will not get
slouken@3407
    38
 *      the results you expect. :)
slouken@1895
    39
 */
slouken@649
    40
slouken@648
    41
#ifndef _SDL_loadso_h
slouken@648
    42
#define _SDL_loadso_h
slouken@648
    43
slouken@1356
    44
#include "SDL_stdinc.h"
slouken@1358
    45
#include "SDL_error.h"
slouken@1356
    46
slouken@648
    47
#include "begin_code.h"
slouken@648
    48
/* Set up for C function definitions, even when using C++ */
slouken@648
    49
#ifdef __cplusplus
slouken@648
    50
extern "C" {
slouken@648
    51
#endif
slouken@648
    52
slouken@3407
    53
/**
slouken@3407
    54
 *  This function dynamically loads a shared object and returns a pointer
slouken@3407
    55
 *  to the object handle (or NULL if there was an error).
slouken@3407
    56
 *  The 'sofile' parameter is a system dependent name of the object file.
slouken@648
    57
 */
slouken@1895
    58
extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
slouken@648
    59
slouken@3407
    60
/**
slouken@8210
    61
 *  This function returns a handle to an already-loaded shared object and 
slouken@8210
    62
 *  returns a pointer to the object handle. If the object file was not loaded
slouken@8210
    63
 *  the function returns NULL. This function adds a reference to the shared
slouken@8210
    64
 *  object, so the caller should call SDL_UnloadObject when they are finished
slouken@8210
    65
 *  with this reference to ensure that the object can be unloaded.
slouken@8210
    66
 *  The 'sofile' parameter is a system dependent name of the object file.
slouken@8210
    67
 */
slouken@8210
    68
extern DECLSPEC void *SDLCALL SDL_GetLoadedObject(const char *sofile);
slouken@8210
    69
slouken@8210
    70
/**
slouken@3407
    71
 *  Given an object handle, this function looks up the address of the
slouken@3407
    72
 *  named function in the shared object and returns it.  This address
slouken@3407
    73
 *  is no longer valid after calling SDL_UnloadObject().
slouken@648
    74
 */
slouken@1895
    75
extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
slouken@1895
    76
                                               const char *name);
slouken@648
    77
slouken@3407
    78
/**
slouken@3407
    79
 *  Unload a shared object from memory.
slouken@3407
    80
 */
slouken@648
    81
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
slouken@648
    82
slouken@648
    83
/* Ends C function definitions when using C++ */
slouken@648
    84
#ifdef __cplusplus
slouken@648
    85
}
slouken@648
    86
#endif
slouken@648
    87
#include "close_code.h"
slouken@648
    88
slouken@648
    89
#endif /* _SDL_loadso_h */
slouken@1895
    90
slouken@1895
    91
/* vi: set ts=4 sw=4 expandtab: */