/*$Id: dlregis.c 1.13 04/03/01 16:51:48-06:00 sarich@lully.mcs.anl.gov $*/

#include "tao_solver.h"

EXTERN_C_BEGIN
#undef __FUNCT__  
#define __FUNCT__ "DLLibraryRegister"
/*
  DLLibraryRegister - This function is called when the dynamic library it is in is opened.

  This registers all of the TAO methods that are in the basic libtao library.

  Input Parameter:
  path - library path
 */
int DLLibraryRegister(const char *path)
{
  int info;
  TaoFunctionBegin;

#ifdef TAO_USE_PETSC
  info = PetscInitializeNoArguments(); if (info) return 1;
#endif

  /*
      If we got here then PETSc was properly loaded
  */
  info = TaoRegisterAll(path);CHKERRQ(info);
  TaoFunctionReturn(0);
}
EXTERN_C_END

/* --------------------------------------------------------------------------*/
static const char *contents = "TAO unconstrained minimization library. \n\
     limited memory variable metric method\n\
     line search Newton method\n\
     trust region Newton method\n";

static const char *authors = TAO_AUTHOR_INFO;
static const char *version = TAO_VERSION_NUMBER;

/* --------------------------------------------------------------------------*/
EXTERN_C_BEGIN
#undef __FUNCT__  
#define __FUNCT__ "DLLibraryInfo"
int DLLibraryInfo(const char *path,const char *type,const char **mess) 
{ 
  int        info;
  TaoTruth iscon,isaut,isver;

  TaoFunctionBegin; 

  info = TaoStrcmp(type,"Contents",&iscon);CHKERRQ(info);
  info = TaoStrcmp(type,"Authors",&isaut);CHKERRQ(info);
  info = TaoStrcmp(type,"Version",&isver);CHKERRQ(info);
  if (iscon)      *mess = contents;
  else if (isaut) *mess = authors;
  else if (isver) *mess = version;
  else            *mess = 0;
  TaoFunctionReturn(0);
}
EXTERN_C_END
