/* ======================================================================== */
/* = Name            : ListSVPs V11.3					  = */
/* =									  = */
/* ======================================================================== */
/* = Autor/Copyright : (c) 1994-95 by Andreas R. Kleinert.                = */
/* =		       All rights reserved.				  = */
/* ======================================================================== */
/* = Function	     : Show available SVOperators                         = */
/* =		                                                          = */
/* ======================================================================== */
/* = Last Update     : 02.04.1995				          = */
/* =									  = */
/* ======================================================================== */
/* = Comments        : "superview.library" V11+ needed.                   = */
/* =									  = */
/* ======================================================================== */
/* = Compiler	     : SAS/C V6.55  					  = */
/* =		       (smakefile)                                        = */
/* ======================================================================== */

#include <superview/superviewbase.h>
#include <svoperators/svoperatorbase.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/superview.h>
#include <proto/svoperators.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


   /* Help- and Info- Texts */

char entry1_text  [] = "\2331;32;40mListSVPs V11.3 \2330;32;40m\2333;32;40m(FREEWARE)\2330;32;40m\n(c) 1994-95 by Andreas Ralph Kleinert.\nAndreas R. Kleinert, Grube Hohe Grethe 23, D-57074 Siegen, Germany.\n";
char entry2_text  [] = "Lists up available \42svoperators\42 of \42superview.library\42.\n";
char entry3_text  [] = "USAGE : \2330;33;40mListSVPs\2330;31;40m\n";

char ver_text [] = "\0$VER: ListSVPs V11.3 (2.4.95)";


/* *************************************************** */
/* *						     * */
/* * Error-Messages for Leave() and KF_Message()     * */
/* *						     * */
/* *************************************************** */

char svlib_text [] = "You need \42superview.library\42 V11+ !";


/* *************************************************** */
/* *						     * */
/* * Function Declarations			     * */
/* *						     * */
/* *************************************************** */

void __regargs Leave(char *endtext, long code);


   /* Functions from module "ListSVPs_Subs.o" : */

extern void __stdargs K_Printf(char *formatstring, ...);


/* *************************************************** */
/* *						     * */
/* * Additional Base Declarations		     * */
/* *						     * */
/* *************************************************** */

extern struct ExecBase *SysBase;

struct SuperViewBase *SuperViewBase = N;


/* *************************************************** */
/* *						     * */
/* * MAIN					     * */
/* *						     * */
/* *************************************************** */

void main(long argc, char **argv)
{
 struct List             *opr_list = N;
 struct SVP_OperatorNode *svp_node = N;

 if(!argc) exit(0); /* started from WB ... */

 if( argc > 3 || (argv[1][0] =='?')||(argv[2][0] =='?'))
  {
   K_Printf("%s%s%s", entry1_text, entry2_text, entry3_text);

   Leave(N, 0);
  }

 SuperViewBase = (struct SuperViewBase *) OpenLibrary("superview.library", 11);
 if(!SuperViewBase) Leave(svlib_text, 100);

 K_Printf("\nList of available svoperators :\n");

 opr_list = &SuperViewBase->svb_SVOperatorList;

 for(svp_node=(APTR) opr_list->lh_Head;(svp_node)&&(svp_node!=(APTR) &(opr_list->lh_Tail));)
  {
   K_Printf("\n  --------------------------------------------------------");

   K_Printf("\nSVOperator  : \42%s\42", svp_node->svp_FileName);
   K_Printf("\nPriority    : %ld",      (long) ((struct Node *)svp_node)->ln_Pri);
   K_Printf("\nDescription : \42%s\42", svp_node->svp_Description);
   K_Printf("\nAuthor      : \42%s\42", svp_node->svp_Author);

   svp_node = (APTR) ((struct Node *)svp_node)->ln_Succ;
  }

 K_Printf("\n  --------------------------------------------------------\n");

 Leave(N, 0);
}

/* *************************************************** */
/* *						     * */
/* * LEAVE : Global Exit Function Replacement	     * */
/* *						     * */
/* *************************************************** */

void __regargs Leave(char *endtext, long code)
{
 if(SuperViewBase) CloseLibrary((APTR) SuperViewBase);

 if(endtext)       K_Printf("%s\n", endtext);

 exit(code);
}
