/*********************************************************
 * Gotcha library example code.
 * (c)1995 Thomas Bickel. All rights reserved.
 *
 * Obtains the list of available Gotcha ARexx ports, shows
 * the list and frees it finaly.
 *********************************************************/
#include <stdio.h>

#include <exec/lists.h>
#include <clib/exec_protos.h>
#include <pragmas/exec_pragmas.h>

#include <clib/gotchalib_protos.h>
#include <pragmas/gotchalib_pragmas.h>
#include <libraries/gotchalib.h>

struct Library *GotchaLibBase;
struct List *gl;
struct Node *nn;
/***********************************************************************/
int main(long argc, char *argv[])
{
	if (GotchaLibBase = OpenLibrary("gotcha.library",1)) {

		if (gl = GL_DupGotchaPortList()) {		/* get a copy of the list */

			nn = gl->lh_Head;					/* show it */
			if (NULL == nn->ln_Succ) puts("No ports to list!");
			else
			while (nn->ln_Succ) {
				puts(nn->ln_Name);
				nn = nn->ln_Succ;
			}

			GL_FreeList(gl);					/* free the whole list */
		} else
			puts("Could not obtain the list!");

		CloseLibrary(GotchaLibBase);
	} else
		puts("Could not open 'gotcha.library'!");
}
