Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
611 B

  1. #include "stralloc.h"
  2. #include "buffer.h"
  3. #include "io.h"
  4. #include "errmsg.h"
  5. #include <unistd.h>
  6. int main() {
  7. static stralloc line;
  8. buffer in;
  9. char buf[4096];
  10. int64 fd;
  11. char* home;
  12. long r;
  13. errmsg_iam("buffer_getline");
  14. if (!(home=getenv("HOME"))) die(1,"no $HOME");
  15. if (!stralloc_copys(&line,home) || !stralloc_cats(&line,"/.slrnrc") || !stralloc_0(&line))
  16. die(1,"out of memory");
  17. if (!io_readfile(&fd,line.s))
  18. diesys(1,"could not open ~/.slrnrc");
  19. buffer_init(&in,read,fd,buf,sizeof buf);
  20. while ((r=buffer_getnewline_sa(&in,&line))>0) {
  21. write(1,line.s,line.len);
  22. }
  23. }