home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libc / fgetmfs.c < prev    next >
C/C++ Source or Header  |  1993-09-11  |  782b  |  48 lines

  1. /*
  2.  * fgetmfs family emulation on top of fgetfln
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <sys/types.h>
  8. #include "news.h"
  9. #include <fgetfln.h>
  10. #include <fgetmfs.h>        /* compatibility header */
  11.  
  12. char *
  13. fgetmfs(fp, limit, cont)
  14. FILE *fp;
  15. int limit;
  16. int cont;
  17. {
  18.     if (cont == CONT_NOSPC && limit == -1)
  19.         return cfgetms(fp);
  20.     else if (cont == CONT_NOSPC)
  21.         return csfgetln(fp, limit, 1);
  22.     else if (cont == CONT_SPC)
  23.         return csfgetln(fp, limit, 0);
  24.     else if (limit == -1)
  25.         return fgetms(fp);
  26.     else {
  27.         register char *line = fgetfln(fp, limit, (int *)NULL);
  28.  
  29.         return line == NULL? NULL: strsave(line);
  30.     }
  31. }
  32.  
  33. char *
  34. fgetms(fp)
  35. FILE *fp;
  36. {
  37.     register char *line = fgetln(fp);
  38.  
  39.     return line == NULL? NULL: strsave(line);
  40. }
  41.  
  42. char *
  43. cfgetms(fp)
  44. FILE *fp;
  45. {
  46.     return cfgetln(fp);
  47. }
  48.