home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / xgopher.1.3 / dir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-08  |  2.0 KB  |  85 lines

  1. /* dir.c
  2.    routines to manage the data fields for gopher directories */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19.  
  20. #include <stdio.h>
  21.  
  22. #include "gopher.h"
  23. #include "dir.h"
  24. #include "dirList.h"
  25.  
  26.  
  27.  
  28. /* Directory data management routines:
  29.     newDir()            return ptr to a gopherDir structure
  30.     freeDir(gopherDirP)        free contents of a directory
  31.  
  32.    data access:
  33.     getDirContents(gopherDirP)    return the contents of a directory 
  34.  
  35. */
  36.  
  37.  
  38. /* newDir 
  39.     Return a fresh ready-to-use gopher directory */
  40.  
  41. gopherDirP
  42. newDir()
  43. {
  44.     gopherDirP    dir;
  45.  
  46.     dir = acquireDir();
  47.  
  48.     dir->selectorItem = NULL;
  49.     dir->created = NOT_LOADED;
  50.     initItemList(&(dir->contents));
  51.  
  52.     return dir;
  53. }
  54.  
  55.  
  56. /* freeDir 
  57.     free the contents of a gopher directory */
  58.  
  59. void
  60. freeDir(dir)
  61. gopherDirP    dir;
  62. {
  63.     if (dir == NULL) return;
  64.  
  65.     /* free selector item and directory contents item list */
  66.  
  67.     freeItem(dir->selectorItem);
  68.     freeItemList(&(dir->contents));
  69.  
  70.     releaseDir(dir);
  71.  
  72.     return;
  73. }
  74.  
  75.  
  76. /* getDirContents
  77.     return the contents (item list pointer) of a directory */
  78.  
  79. gopherItemListP
  80. getDirContents(gd)
  81. gopherDirP    gd;
  82. {
  83.     return &(gd->contents);
  84. }
  85.