/*
 *      $Filename: LibraryTest.c $
 *      $Revision$
 *      $Date$
 *
 *      Copyright (C) 1993 by Peter Simons <simons@peti.GUN.de>
 *
 *      This program 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 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
 *      General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 *      $Id$
 *
 * ------------------------------- log history ----------------------------
 * $Log$
 */


/**************************************************************************
 *                                                                        *
 * SEKTION: Labels, Macros, Switches, Structures                          *
 *                                                                        *
 **************************************************************************/

/************************************* Includes ***********/
#include <stdio.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/netsupport.h>
#include <libraries/netsupport.h>
#include <exec/memory.h>

/************************************* Defines ************/

/************************************* Prototypes *********/

static const char __RCSId[] = "$Id$";

/**************************************************************************
 *                                                                        *
 * SEKTION: Main program                                                  *
 *                                                                        *
 **************************************************************************/


int __saveds main(void)
{
        struct NetSupportLibrary *NetSupportBase;
        char buffer[256];
        BPTR fh;
        LONG i;

        if (!(NetSupportBase = (struct NetSupportLibrary *) OpenLibrary(NETSUPPORTNAME, 0L)))
                return 10;

/*
        AllocMemPooled(240, MEMF_PUBLIC|MEMF_CLEAR);
        FreeMemPooled(AllocMemPooled(240, MEMF_ANY));

        Printf("%lu\n", GetSeq(1L));

        Printf("%s\n", TempNameT(buffer));
        Printf("%s\n", TempName(NULL));
        Printf("%s\n", TempNameT(buffer));
        Printf("%s\n", TempName(NULL));
        Printf("%s\n", TempName(buffer));
        Printf("%s\n", TempNameT(NULL));
        Printf("%s\n", TempName(buffer));
        Printf("%s\n", TempNameT(NULL));

        Printf("%s <%s\n", GetConfig(NULL, RMAIL, NULL, RMAIL), "Test");
        System("LibraryTest2", NULL);

        MakeLogEntry(NULL, 0L, "%s:%s", "Test", "Klaus");
        Printf("%s\n", GetConfig("UULIB:PMail.config", "NODENAME", "HOSTNAME", "RAM:"));
        Printf("%s\n", GetConfig(NULL, "NODENAME2", "HOSTNAME", "def"));

        Printf("%ld\n", LockFileAttempt("uuspool:Klaus"));

        LockFile("uuspool:Klaus");
        if (IsFileLocked("uuspool:Klaus"))
                printf("Locked!!\n");
        else
                printf("Not locked!!\n");

        Printf("%s\n", GetConfigEntry("RAM:Test", "NodeName", "<not set>"));
        SetConfigEntry("RAM:Test", "NodeName", "badtaste");
        Printf("%s\n", GetConfigEntry("RAM:Test", "NodeName", "<not set>"));

        if (fh = POpen("sendmail", MODE_PIPETO)) {
                FPuts(fh, "To: postmaster\nSubject: NetSupportLibrary Test\n\n");
                FPuts(fh, "Dies ist nur ein doofer Test von einem doofen Program!\n");
                PClose(fh);
        }

        if (fh = POpen("Type S:Startup-Sequence", MODE_PIPEFROM)) {
                while(FGets(fh, buffer, 255))
                        FPuts(Output(), buffer);
                PClose(fh);
        }

        MakeLogEntry("Test", MLE_DEBUG1, "Debug1");
        MakeLogEntry("Test", MLE_DEBUG2, "Debug2");
        MakeLogEntry("Test", MLE_DEBUG3, "Debug3");
        MakeLogEntry("Test", MLE_DEBUG4, "Debug4");
        MakeLogEntry("Test", MLE_DEBUG5, "Debug5");
        MakeLogEntry("Test", MLE_DEBUG6, "Debug6");
        MakeLogEntry("Test", MLE_DEBUG7, "Debug7");
*/

        if (fh = POpen("ListSERV:c/Cat", MODE_PIPETO)) {
                for (i = 0; i <= 5; i++)
                        FPuts(fh, "Test\n");
                Printf("RC: %ld\n", PClose(fh));
        }

        CloseLibrary((struct Library *) NetSupportBase);
        return 0;
}


