home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / libsmall / sys.slow.c < prev   
Encoding:
C/C++ Source or Header  |  1991-11-14  |  1.5 KB  |  90 lines

  1. /*
  2.  * news sys file reading functions (slow, small, on-disk version)
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include "news.h"
  8. #include "ngmatch.h"
  9. #include "system.h"
  10.  
  11. /* imports */
  12. extern struct system *currsys, *firstsys;
  13.  
  14. /* forwards */
  15. FORWARD void freecurrsys();
  16.  
  17. void
  18. remmysys(sys)
  19. struct system *sys;
  20. {
  21.     /* no cache */
  22. }
  23.  
  24. struct system *
  25. mysysincache()
  26. {
  27.     return NULL;
  28. }
  29.  
  30. /* ARGSUSED */
  31. void
  32. setupsys(fp)                /* reuse currsys */
  33. FILE *fp;
  34. {
  35.     freecurrsys();
  36. }
  37.  
  38. boolean
  39. donesys()
  40. {
  41.     if (firstsys != NULL) {        /* parsed an entry? */
  42.         firstsys = NULL;    /* not cached, but currsys still valid */
  43.         return YES;
  44.     } else
  45.         return NO;        /* was a comment */
  46. }
  47.  
  48. void
  49. rewsys(fp)
  50. FILE *fp;
  51. {
  52.     if (fp != NULL)
  53.         (void) rewind(fp);
  54. }
  55.  
  56. void
  57. advcurrsys()
  58. {
  59.     /*
  60.      * the sys file is not in core, so we must not change currsys
  61.      * to ensure that it gets freed later by freecurrsys().
  62.      */
  63. }
  64.  
  65. /*
  66.  * Free current sys entry & associated memory.  Zero currsys too.
  67.  */
  68. STATIC void
  69. freecurrsys()
  70. {
  71.     if (currsys != NULL) {
  72.         nnfree(&currsys->sy_name);
  73.         nnfree(&currsys->sy_excl);
  74.         /* allow sharing of ngs and distr */
  75.         if (currsys->sy_ngs == currsys->sy_distr)
  76.             currsys->sy_distr = NULL;
  77.         else
  78.             nnfree(&currsys->sy_distr);
  79.         nnfree(&currsys->sy_ngs);
  80.         nnfree(&currsys->sy_cmd);
  81.         /* allow sharing of trngs and trdistr */
  82.         if (currsys->sy_trdistr != currsys->sy_trngs)
  83.             ngfree(currsys->sy_trdistr);
  84.         currsys->sy_trdistr = NULL;
  85.         ngfree(currsys->sy_trngs);
  86.         currsys->sy_trngs = NULL;
  87.         nnafree(&currsys);
  88.     }
  89. }
  90.