/* $Revision Header built by KCommodity by Kai Iske *** (do not edit) ************
**
** © Copyright by H.P.G
**
** File             : Aztec:Source/Installer/Support/IList.c
** Created on       : Tuesday, 28-Jul-92 10:21:45
** Created by       : Hans-Peter Guenther
** Current revision : V0.01
**
**
** Purpose
** -------
**     IList.c Version 0.1 written 1992 by H.P.G PublicDomain Version
**     This is the source code for IList, which gives you simply a list of all
**     currently opened screens and windows. Because of the use of Printf instead
**     of printf it is OS 2.0 only. Exchange Printf with printf and you can run it
**     under 1.3 1.2 too.
**
** Revision V0.01
** --------------
**     --- Initial release ---
**
*********************************************************************************/
#define REVISION "0.01"		/* This is the revision number */
#define REVDATE  "28-Jul-92"		/* This is the revision date */

/* compiler linker options for Manx 5.xx

cc IList
ln IList -lc

*/

#include <exec/types.h>
#include <Intuition/Intuition.h>
#include <Intuition/Intuitionbase.h>
#include <functions.h>

int Enable_Abort=0;
VOID _abort(VOID) {}   /* disables ^C handling */

#define IB IntuitionBase
struct  IB *IB=NULL;

VOID main(int argc,char **argv)
    {
    register struct Screen *Scr;  /* Screen Pointer */
    register struct Window *Wd;   /* Window Pointer */
    register LONG i=1,u=1;        /* Counter Vars   */
    ULONG ilock;                  /* IntuitionLock  */

    if (argv) exit(0);
                    /* I used a special startup code not the normal _main  */
                    /* startup. If you want to recompile it, you have to   */
                    /* exchange this lines to something like:              */
                    /*  if (argc==0) exit(0);                              */
                    /* I my startup I have disbales the cliparsing because */
                    /* of the use of the ReadArgs functions. So argv will  */
                    /* only contain anything, when started from WBench     */

                    /* If you started this program from WBench and the Icon*/
                    /* contains a tooltype entry with `CLI` the WBench     */
                    /* first prompts you to enter the arguments and then   */
                    /* starts the tool as an cli program                   */

    if (!(IB=(struct IB *)OpenLibrary("intuition.library",36L))) exit(0);

    /* if you want to recompile for kickstart versions < 2.0 you can   */
    /* exchange the 36L to 0L . Then you have to exchange the Printf   */
    /* function calls to printf from the c.libs ones                   */

    ilock=LockIBase(1L); /* We got the IntuitionLock */

    if (!(Scr=(struct Screen *)IB->FirstScreen)) goto x1;
    /* check if we got the first Screen if not -> exit */
    do  {
        Printf("%ld.\033[32m Screen: %20s \033[31m\n"
               "-------------------------------------------------------------------------\n"
               "\tLeftEdge: %ld TopEdge: %ld Width: %ld Height: %ld\n"
               "\tFlags: %ld\n",
               i,
               Scr->Title,
               Scr->LeftEdge,
               Scr->TopEdge,
               Scr->Width,
               Scr->Height,
               Scr->Flags);
        /* putting out the screen data */
        if (Wd=(struct Window *)Scr->FirstWindow)
            {
            do {
               Printf("\t%ld.\033[32m Window: %15s\033[31m \n"
                      "\t\tLeftEdge: %ld TopEdge: %ld Width: %ld Height: %ld\n"
                      "\t\tWindowFlags: %ld IDCMPFlags: %ld\n",
                      u,Wd->Title,
                      Wd->LeftEdge,
                      Wd->TopEdge,
                      Wd->Width,
                      Wd->Height,
                      Wd->Flags,
                      Wd->IDCMPFlags);
               /* putting out the window data */
               u++;
               }while(Wd=(struct Window *)Wd->NextWindow);
            } /* if */
        u=1;
        i++;
    }while(Scr=(struct Screen *)Scr->NextScreen);

    x1:

    UnlockIBase(ilock);                          /* Free IntuitionLock   */
    if (IB) CloseLibrary((struct Library *)IB);  /* close IBase          */
    exit(0);
    }

