home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk10 / apps / ds / ds.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  2.3 KB  |  102 lines

  1. /***    ds.c - Display Subdirectories
  2. *
  3. *    Display subdirectories in tree form.  This example paints a directory
  4. *    tree on the screen using VIO calls.  USER=drive:path must be in the
  5. *    enviornment. It determines where the initialization file is kept. The
  6. *    first time this program is called, it creates a new initialization file
  7. *    and builds the display tree from the current directory.
  8. *
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. #include "ds.h"
  14. #include "vars.h"
  15.  
  16. extern buildTree (Directory *, char *);
  17. extern decorateTree (Directory *);
  18. extern clearBottomLine ();
  19. extern clearScreen();
  20. extern fileInit ();
  21. extern getState ();
  22. extern handleDisplay (Directory *);
  23. extern helpInit ();
  24. extern optionInit ();
  25. extern refreshDisplay (int, Directory *);
  26. extern saveState ();
  27. extern screenInit ();
  28.  
  29. /***    main - entry point to DS program
  30. *
  31. *
  32. */
  33. main (argc,argv,envp)
  34. int argc;
  35. char *argv[];
  36. char *envp[];
  37. {
  38.     initialize ();
  39.     if (root->d_child) {        /* There is a tree to display */
  40.     decorateTree (root);
  41.     handleDisplay (root);
  42.     }
  43.     else {                /* No tree */
  44.     VIOSETCURPOS (WINDOW_TOP+2,0, VioHandle); /* Avoid scrolling error */
  45.     fprintf (stderr, "\nNo subdirectories in this directory.\n");
  46.     exitError (2);
  47.     }
  48.     if (stateModified)
  49.     saveState ();            /* Save colors */
  50.     cleanUp ();
  51. }   /* main */
  52.  
  53.  
  54. /***    initialize - initialize components of DS program
  55. *
  56. *
  57. */
  58. initialize ()
  59. {
  60.     int rCode;
  61.  
  62.     fileInit ();            /* Init path and file stuff */
  63.     screenInit ();            /* Init the physical screen */
  64.     helpInit ();            /* Initialize help screen */
  65.     optionInit ();            /* Initialize option screen */
  66.     rCode = getState ();        /* Read initialization file */
  67.     clearScreen ();            /* Clear screen */
  68.     refreshDisplay (-1, NULL);        /* Display screen header */
  69.     if (!rCode) {            /* Init file bad */
  70.     newDir (&root,"\0",0);        /* Make root node */
  71.     buildTree (root,IntRootPath);    /* Build directory tree */
  72.     stateModified = TRUE;
  73.     }
  74.     else
  75.     stateModified = FALSE;
  76.     return;
  77.  
  78. }   /* initialize */
  79.  
  80.  
  81.  
  82. /***    exitError - clean up and exit with error code
  83. *
  84. *
  85. */
  86. exitError (code)
  87. int code;
  88. {
  89.     cleanUp ();
  90.     exit (code);
  91. }   /* exitError */
  92.  
  93.  
  94. /***    cleanUp - clean up before exit
  95. *
  96. *
  97. */
  98. cleanUp ()
  99. {
  100.     clearBottomLine ();         /* Don't leave garbage if using vt52.sys */
  101. }   /* cleanUpUp */
  102.