
/* 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;


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

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

    screen = IntuitionBase->FirstScreen;

    Forbid();

    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)
struct Screen *screen;
{
    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)
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");
}

