|
|
1.1 ! root 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 */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.