/*
This source file is part of Scol
For the latest info, see http://www.scolring.org

Copyright (c) 2011 Stephane Bisaro, aka Iri <iri@irizone.net>

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

This program 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt

For others informations, please contact us from http://www.scolring.org/
*/


/*

    INCLUDED FILES

*/

#include "main.h"


#if defined _WIN32 || defined __WIN32__
cbmachine ww;
#endif
mmachine  mm;



/*
    Library initialization and loader
*/
int SCOLinitNetClass (mmachine m)
{
    int k;

    MMechostr(MSKDEBUG, "SCOLinitNetClass: loading\n");

    net_connection_init ();

    if ((k = SCOLftpLoadAPI (m))) return k;     /* ftp */
    if ((k = SCOLnetworksLoadAPI (m))) return k;    /* networks */

    return k;
}


#if defined _WIN32 || defined __WIN32__
# define SCOL_NET_PLUGIN_EXPORT __declspec (dllexport)
#elif defined linux || defined __linux
# define SCOL_NET_PLUGIN_EXPORT
#else
# error no platform supported
#endif

SCOL_NET_PLUGIN_EXPORT int ScolLoadPlugin (mmachine m, cbmachine w)
{
    ww = w;
    mm = m;

    SCOLinitplugin (w);
    return SCOLinitNetClass (m);
}

/*
  Fonction de déchargement de la librairie
*/
SCOL_NET_PLUGIN_EXPORT int ScolUnloadPlugin ()
{
    #if ((defined _WIN32) || (defined __WIN32__))
    if (WSACleanup () == SOCKET_ERROR)
        MMechostr (0, "error WSACleanup : %d", errno);
    #endif
    return 0;
}



