home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 144.lha / VScreen_Src / wList.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  2.2 KB  |  94 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. #define INTUITION_REV   0L
  7. extern struct IntuitionBase *IntuitionBase;
  8. extern struct IntuitionBase *OpenLibrary();
  9. static void ShowUsage()
  10. {
  11.    printf("Usage:  WLIST [screen]\n");
  12.    exit(10L);
  13. }
  14. static struct Screen *FindScreen(ScreenName)
  15. --MORE--(71%)char *ScreenName;
  16. {
  17.    struct Screen *theScreen;
  18.    if (ScreenName && ScreenName[0])
  19.    {
  20.       Forbid();
  21.       theScreen = IntuitionBase->FirstScreen;
  22.       while (theScreen && (theScreen->Title == NULL ||
  23.              stricmp(theScreen->Title,ScreenName) != 0))
  24.                 theScreen = theScreen->NextScreen;
  25.       Permit();
  26.    } else {
  27.       Forbid();
  28.       theScreen = IntuitionBase->FirstScreen;
  29.       Permit();
  30.    }
  31.    if (theScreen == NULL)
  32.    {
  33.       Permit();
  34.       printf("Can't find screen '%s'\n",ScreenName);
  35.       exit(10L);
  36. --MORE--(73%)   }
  37.    return(theScreen);
  38. }
  39. static void PrintWindowTitle(theWindow)
  40. struct Window *theWindow;
  41. {
  42.    if (theWindow && theWindow->Title)
  43.       printf("   '%s'\n",theWindow->Title);
  44.      else
  45.       printf("   [No Title]\n");
  46. }
  47. static void PrintScreenTitle(theScreen)
  48. struct Screen *theScreen;
  49. {
  50.    if (theScreen && theScreen->Title)
  51.       printf("'%s'\n",theScreen->Title);
  52.      else
  53.       printf("[No Title]\n");
  54. }
  55. --MORE--(74%)
  56. static void PrintScreenWindows(theScreen)
  57. struct Screen *theScreen;
  58. {
  59.    struct Window *theWindow = theScreen->FirstWindow;
  60.    
  61.    while (theWindow)
  62.    {
  63.       PrintWindowTitle(theWindow);
  64.       theWindow = theWindow->NextWindow;
  65.    }
  66. }
  67. void main(argc,argv)
  68. int argc;
  69. char *argv[];
  70. {
  71.    char *ScreenName = NULL;
  72.    struct Screen *theScreen;
  73.    if (argc > 2) ShowUsage();
  74.    if (argc > 1 && argv[1] && argv[1][0] != '\0') ScreenName = argv[1];
  75. --MORE--(75%)   
  76.    IntuitionBase = OpenLibrary("intuition.library",INTUITION_REV);
  77.    if (IntuitionBase)
  78.    {
  79.       theScreen = FindScreen(ScreenName);
  80.       printf("\n");
  81.       while (theScreen)
  82.       {
  83.          PrintScreenTitle(theScreen);
  84.          PrintScreenWindows(theScreen);
  85.          if (ScreenName)
  86.             theScreen = NULL;
  87.            else
  88.             theScreen = theScreen->NextScreen;
  89.       }
  90.       printf("\n");
  91.       CloseLibrary(IntuitionBase);
  92.    }
  93. }
  94.