home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1988, The Trustees of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- #ifndef lint
- static char *SCCSid = "@(#)macaux.c 1.1 9/19/88";
- #endif lint
-
- #include <ctype.h>
- #include <stdio.h>
-
- char *Fgets(b, n, fp)
- char *b;
- register int n;
- register FILE *fp;
- {
- register int c;
- register char *cp = b;
-
- while(--n > 0) {
- if((c = getc(fp)) == EOF) {
- if(cp > b)
- break;
- else
- return(NULL);
- }
- if(isascii(c) && !isprint(c)) {
- if(c == '\n' || c == '\r') {
- *cp++ = '\n';
- *cp = 0;
- return(b);
- } else if(c == 0)
- c = 0200;
- }
- *cp++ = c;
- }
- *cp = 0;
- return(b);
- }
-
- Fputs(b, fp)
- register char *b;
- register FILE *fp;
- {
- while(*b) {
- if(*b & 0200) {
- if((*b & 0177) == 0)
- *b = 0;
- fprintf(fp, "\\%03o", *b);
- } else if(!isprint(*b) && *b != '\n' && *b != '\t')
- fprintf(fp, "\\%03o", *b);
- else
- putc(*b, fp);
- b++;
- }
- }
-