Copyright (C) Kevin Larke 2009-2020

This file is part of libcm.

libcm is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

libcm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See the GNU General Public License distributed with the libcm package or look here: .


cmLib : Manage shared-libraries and query them for known symbols.

enum
{
  kOkLibRC = cmOkRC,
  kOpenFailLibRC,
  kCloseFailLibRC,
  kSymFailLibRC,
  kInvalidIdLibRC,
  kFileSysFailLibRC
  
};

typedef unsigned   cmLibRC_t;
typedef cmHandle_t cmLibH_t; 


extern cmLibH_t cmLibNullHandle;

// Initialize a dynamic library manager and scan a directory for dynamic libraries
// to load. 'dirStr' is optional.
cmLibRC_t cmLibInitialize( cmCtx_t* ctx, cmLibH_t* hp, const cmChar_t* dirStr );

// Release a dynamic library manager and close any open libraries it may own.
cmLibRC_t cmLibFinalize(   cmLibH_t* hp );

// Return true if the dynamic library mgr. is initialized.
bool      cmLibIsValid( cmLibH_t h );

// Open a dynamic library.
// Return cmInvalidId on error.
unsigned  cmLibOpen(  cmLibH_t h, const cmChar_t* libFn );

// Close a dynamic library.
cmLibRC_t cmLibClose( cmLibH_t h, unsigned libId );

// Return a pointer to a symbol from a dynamic library.
void*     cmLibSym( cmLibH_t h, unsigned libId, const cmChar_t* fn );

// Scan a directory for dynamic libraries.
cmLibRC_t cmLibScan( cmLibH_t h, const cmChar_t* dirStr );

// Return the count of open libraries.
unsigned  cmLibCount( cmLibH_t h );

// Return a library id given an index
unsigned  cmLibIndexToId( cmLibH_t h, unsigned idx );

// Return the libraries file name.
const cmChar_t* cmLibName( cmLibH_t h, unsigned libId );