
/* gosh, this goes way way way back, one of my very first Amiga programs...

   John Russell */

/* include all the standard stuff for intuition */

#include "intuition/intuitionbase.h"

struct IntuitionBase *IntuitionBase;

_cli_parse() {}
_wb_parse() {}
_abort() {}

main()
{
    register struct Screen *screen;
    register struct Window *window;
    register struct MenuItem *menuitem;
    register struct Menu *menu;
    register long ILock;

    if ((IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0L))==NULL)
    {
            printf("Where is Intuition gone???\n");
            exit(10);
    }

    Forbid();

    screen = IntuitionBase->FirstScreen;

    printf("First screen title is \"%s\".\n",screen->Title ? screen->Title :
        "<NULL>");

    do_windows(screen);

    while (screen->NextScreen != NULL) {
        screen = screen->NextScreen;
        printf("Another screen is titled \"%s\".\n",screen->Title ? screen->Title
            : "<NULL>");
        do_windows(screen);
    }

    printf("No more screens.\n");

    Permit();

    CloseLibrary(IntuitionBase);

}

do_windows(screen)
register struct Screen *screen;
{
    register struct Window *window;

    window = screen->FirstWindow;
    printf("\tThe first window is titled \"%s\".\n",window->Title ? window->Title
        : "<NULL>");
    do_menus(window->MenuStrip);

    while (window->NextWindow != NULL) {
        window = window->NextWindow;
        printf("\tAnother window title is \"%s\".\n",window->Title ? window->Title
            : "<NULL>");
        do_menus(window->MenuStrip);
    }

    printf("\tNo more windows.\n");
}

do_menus(menu)
register struct Menu *menu;
{
    while (menu != NULL) {
        printf("\t\tMenu title: \"%s\".\n",menu->MenuName ? menu->MenuName :
            "<NULL");
        menu = menu->NextMenu;
    }
    printf("\t\tNo more menus.\n");
}

