/* ======================================================================== */
/* = Programmname    : ListSPOs V7.2					  = */
/* =									  = */
/* ======================================================================== */
/* = Autor/Copyright : (c) 1994-97 by Andreas R. Kleinert.                = */
/* =		       All rights reserved.				  = */
/* ======================================================================== */
/* = Funktion	     : Shows available SPObjects of superplay.library.    = */
/* =		                           		                  = */
/* ======================================================================== */
/* = Letztes Update  : 15.8.1997				                  = */
/* =									  = */
/* ======================================================================== */
/* = Bemerkungen     : Needs "superplay.library" V7+.                     = */
/* =									  = */
/* ======================================================================== */
/* = Compiler	     : SAS/C V6.58 					  = */
/* =		       (smakefile)                                        = */
/* ======================================================================== */

#define __USE_SYSBASE

#include <superplay/superplaybase.h>
#include <SPObjects/SPObjectbase.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/superplay.h>

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


   /* Help- and Info- Texts */

char entry1_text  [] = "\2331;32;40mListSPOs V7.2 \2330;32;40m\2333;32;40m(FREEWARE)\2330;32;40m\n(c) 1994-97 by Andreas Ralph Kleinert.\nAndreas R. Kleinert, Sandstrasse 1, D-57072 Siegen, Germany.\n";
char entry2_text  [] = "Lists up available \42SPObjects\42 of \42superplay.library\42.\n";
char entry3_text  [] = "USAGE : \2330;33;40mListSPOs\2330;31;40m\n";

char ver_text [] = "\0$VER: ListSPOs 7.2 (15.8.97)";


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

char splib_text [] = "You need \42superplay.library\42 V7+ !";


/* *************************************************** */
/* *						     * */
/* * MACROs for Version-Tests			     * */
/* *						     * */
/* *************************************************** */

#define LibVer(x) ( ((struct Library *) x)->lib_Version )
#define OS_VER	  LibVer(SysBase)


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

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


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

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


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

extern struct ExecBase *SysBase;

struct SuperPlayBase *SuperPlayBase = N;


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

void main(long argc, char **argv)
{
 struct List           *obj_list = N;
 struct SPO_ObjectNode *spo_node = N;
 long i;

 if(argc==0) Leave(N, FALSE);

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

   Leave(N, 0);
  }

 SuperPlayBase = (struct SuperPlayBase *) OpenLibrary("superplay.library", 7);
 if(!SuperPlayBase) Leave(splib_text, 100);

 SP_Printf("\nList of available SPObjects :");

 obj_list = &SuperPlayBase->spb_SPObjectList;

 for(spo_node=(APTR) obj_list->lh_Head;(spo_node)&&(spo_node!=(APTR) &(obj_list->lh_Tail));)
  {
   SP_Printf("\n\n");

   SP_Printf("\nSPObject : \42%s\42", spo_node->spo_FileName);
   SP_Printf("\nSPO-Type : %lx",      spo_node->spo_ObjectType);
   SP_Printf("\nPriority : %ld",      (long) ((struct Node *)spo_node)->ln_Pri);
   SP_Printf("\nTypeID   : \42%s\42", spo_node->spo_TypeID);
   SP_Printf("\nTypeCode : %ld",      spo_node->spo_TypeCode);

   if(spo_node->spo_BackgroundReplay) SP_Printf("\nKind     : BackGround-Player");
    else                              SP_Printf("\nKind     : Synchron-Player");

   for(i=0; i<spo_node->spo_SubTypeNum; i++)
    {
     SP_Printf("\n\n%ld. SubType     :", i+1);
     SP_Printf("\n   SubTypeID   : \42%s\42", spo_node->spo_SubTypeID[i]);
     SP_Printf("\n   SubTypeCode : %ld",      spo_node->spo_SubTypeCode[i]);
    }

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

 SP_Printf("\n\nNo more SPObjects available.\n\n");

 Leave(N, 0);
}

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

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

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

 exit(code);
}
