/* get the attributes of the file associated with the name; do not follow any symbolic links */ if (lstat(file, &buf) < 0) goto error; if ((buf.st_mode&S_IFLNK) == S_IFLNK){ fprintf(stderr, "%s is a symbolic link\n", file); goto error; } /* open the file, write to it, and close it */ if ((fp = fopen(file, "a")) == NULL) goto error; while(fgets(buf, BUFSIZ, stdin) != NULL) fputs(buf, fp); (void) fclose(fp);
Matt Bishop Office: 3059 Engineering Unit II Phone: +1 (530) 752-8060 Fax: +1 (530) 752-4767 Email: [email protected] | Copyright Matt Bishop, 2000. All federal and state copyrights reserved for all original material presented in this course through any medium, including lecture or print. |