home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d4xx / d494 / vscreen.lha / vScreen / Utilities / Source / wList.c < prev    next >
C/C++ Source or Header  |  1991-06-06  |  2KB  |  110 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuitionbase.h>
  3. #include <intuition/screens.h>
  4. #include <proto/intuition.h>
  5. #include <proto/exec.h>
  6.  
  7. #define INTUITION_REV   0L
  8. extern struct IntuitionBase *IntuitionBase;
  9. extern struct IntuitionBase *OpenLibrary();
  10.  
  11.  
  12. static void ShowUsage()
  13. {
  14.    printf("Usage:  WLIST [screen]\n");
  15.    exit(10L);
  16. }
  17.  
  18.  
  19. static struct Screen *FindScreen(ScreenName)
  20. char *ScreenName;
  21. {
  22.    struct Screen *theScreen;
  23.  
  24.    if (ScreenName && ScreenName[0])
  25.    {
  26.       Forbid();
  27.       theScreen = IntuitionBase->FirstScreen;
  28.       while (theScreen && (theScreen->Title == NULL ||
  29.              stricmp(theScreen->Title,ScreenName) != 0))
  30.                 theScreen = theScreen->NextScreen;
  31.       Permit();
  32.    } else {
  33.       Forbid();
  34.       theScreen = IntuitionBase->FirstScreen;
  35.       Permit();
  36.    }
  37.  
  38.    if (theScreen == NULL)
  39.    {
  40.       Permit();
  41.       printf("Can't find screen '%s'\n",ScreenName);
  42.       exit(10L);
  43.    }
  44.    return(theScreen);
  45. }
  46.  
  47.  
  48. static void PrintWindowTitle(theWindow)
  49. struct Window *theWindow;
  50. {
  51.    if (theWindow && theWindow->Title)
  52.       printf("   '%s'\n",theWindow->Title);
  53.      else
  54.       printf("   [No Title]\n");
  55. }
  56.  
  57. static void PrintScreenTitle(theScreen)
  58. struct Screen *theScreen;
  59. {
  60.    if (theScreen && theScreen->Title)
  61.       printf("'%s'\n",theScreen->Title);
  62.      else
  63.       printf("[No Title]\n");
  64. }
  65.  
  66.  
  67. static void PrintScreenWindows(theScreen)
  68. struct Screen *theScreen;
  69. {
  70.    struct Window *theWindow = theScreen->FirstWindow;
  71.    
  72.    while (theWindow)
  73.    {
  74.       PrintWindowTitle(theWindow);
  75.       theWindow = theWindow->NextWindow;
  76.    }
  77. }
  78.  
  79.  
  80. void main(argc,argv)
  81. int argc;
  82. char *argv[];
  83. {
  84.    char *ScreenName = NULL;
  85.    struct Screen *theScreen;
  86.  
  87.    if (argc > 2) ShowUsage();
  88.    if (argc > 1 && argv[1] && argv[1][0] != '\0') ScreenName = argv[1];
  89.    
  90.    IntuitionBase = OpenLibrary("intuition.library",INTUITION_REV);
  91.    if (IntuitionBase)
  92.    {
  93.       theScreen = FindScreen(ScreenName);
  94.  
  95.       printf("\n");
  96.       while (theScreen)
  97.       {
  98.          PrintScreenTitle(theScreen);
  99.          PrintScreenWindows(theScreen);
  100.          if (ScreenName)
  101.             theScreen = NULL;
  102.            else
  103.             theScreen = theScreen->NextScreen;
  104.       }
  105.       printf("\n");
  106.       CloseLibrary(IntuitionBase);
  107.    }
  108. }
  109.  
  110.