> Here we see several wishes:
> $ echo wow|mpack -o /dev/stdout /dev/stdin
> Subject: File exists

> i.e., why no stdin, stdout options? Also don't prompt for subject if
> stdin is not a terminal.

The patch below fixes the stdout part. It opens character devices
without O_CREAT and O_EXCL.

(stdin is more difficult, there is rewind() in magic.c; and I didn't
understand the Subject: prompting code.)

        Sven

-----
diff -c -r mpack-1.6.original/unixos.c mpack-1.6/unixos.c
*** mpack-1.6.original/unixos.c Thu Apr 21 14:40:25 2005
--- mpack-1.6/unixos.c  Thu Apr 21 15:02:18 2005
***************
*** 28,33 ****
--- 28,34 ----
  #include <errno.h>
  #include <sys/types.h>
  #include <sys/param.h>
+ #include <sys/stat.h>
  #include <netdb.h>
  #include <fcntl.h>
  #include "xmalloc.h"
***************
*** 139,145 ****
      FILE *ret;
       
  #ifdef O_EXCL
!     fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
  #else
      fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
  #endif
--- 140,155 ----
      FILE *ret;
       
  #ifdef O_EXCL
!     struct stat statbuf;
! 
!     if ((stat(fname, &statbuf) == 0) && (S_ISCHR(statbuf.st_mode)))
!       {
!       fd=open(fname, O_RDWR);
!       }
!     else
!       {
!       fd=open(fname, O_RDWR|O_CREAT|O_EXCL, 0644);
!       }
  #else
      fd=open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644);
  #endif


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to