1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Description: Allow '-' as an alias for the standard input or output stream.
Forwarded: no
Author: Miriam Ruiz <little_miry@yahoo.es>
Last-Update: 2007-07-31
Index: fenix-0.92a.dfsg1/include/files_st.h
===================================================================
--- fenix-0.92a.dfsg1.orig/include/files_st.h 2007-08-28 14:38:36.000000000 +0200
+++ fenix-0.92a.dfsg1/include/files_st.h 2007-08-28 14:40:08.000000000 +0200
@@ -39,6 +39,7 @@
#define F_XFILE 1
#define F_FILE 2
#define F_GZFILE 3
+#define F_STDFILE 4
#include <zlib.h>
Index: fenix-0.92a.dfsg1/common/files.c
===================================================================
--- fenix-0.92a.dfsg1.orig/common/files.c 2007-08-28 14:38:36.000000000 +0200
+++ fenix-0.92a.dfsg1/common/files.c 2007-08-28 14:44:28.000000000 +0200
@@ -460,6 +460,31 @@
memset (f, 0, sizeof(file)) ;
strncpy (f->name, filename, MAX_PATH);
+ if (strcmp(filename, "-") == 0 && strchr(mode,'r'))
+ {
+ char buffer[1024];
+ size_t buflen;
+ f->type = F_FILE;
+ f->fp = tmpfile();
+ opened_files++;
+
+ while ((buflen = fread(buffer, 1, sizeof(buffer), stdin)))
+ {
+ fwrite(buffer, 1, buflen, f->fp);
+ }
+ fseek (f->fp, 0, SEEK_SET);
+
+ return f ;
+ }
+
+ if (strcmp(filename, "-") == 0 && strchr(mode,'w'))
+ {
+ f->type = F_STDFILE;
+ f->fp = stdout;
+ opened_files++;
+ return f ;
+ }
+
c = filename ;
for (n = c+strlen(c) ; n >= c ; n--)
{
|