'-f' flag is working now.
authorshort <>
Thu, 29 Jul 1999 14:39:38 +0000 (14:39 +0000)
committershort <>
Thu, 29 Jul 1999 14:39:38 +0000 (14:39 +0000)
mdsms.c

diff --git a/mdsms.c b/mdsms.c
index a7a9905..39a9c03 100644 (file)
--- a/mdsms.c
+++ b/mdsms.c
@@ -5,6 +5,9 @@ static char rcsid[] ATTR_UNUSED = "$Id$";
 
 /*
  * $Log$
 
 /*
  * $Log$
+ * Revision 1.7  1999/07/29 14:39:38  short
+ * '-f' flag is working now.
+ *
  * Revision 1.6  1999/07/28 10:46:37  short
  * Removed strict converting/checking of symbol characters to '?'.
  *
  * Revision 1.6  1999/07/28 10:46:37  short
  * Removed strict converting/checking of symbol characters to '?'.
  *
@@ -834,19 +837,28 @@ char *buf=malloc(l+50);
                finame=body;
                body=NULL;
                }
                finame=body;
                body=NULL;
                }
-       else fin=stdin;
+       else {
+               finame=NULL;
+               fin=stdin;
+               }
        if (!body) {
                readbody=0;
        if (!body) {
                readbody=0;
-               if (verbose>=1)
-                       error("\nPlease enter the SMS text body, end with EOF (ctrl-D):");
+               if (!finame) {
+                       if (verbose>=1)
+                               error("\nPlease enter the SMS text body, end with EOF (ctrl-D):");
+                       }
+               else {
+                       if (!(fin=fopen(finame,"rt")))
+                               error("!Can't open data file \"%s\" for r/o: %m",finame);
+                       }
                chk(body=malloc(BODYLOAD));
                bodylen=fread(body,1,BODYLOAD,fin);
                if (bodylen==-1)
                        error("!Error reading stream \"%s\": %m",(finame?finame:"<stdin>"));
                chk(body=malloc(BODYLOAD));
                bodylen=fread(body,1,BODYLOAD,fin);
                if (bodylen==-1)
                        error("!Error reading stream \"%s\": %m",(finame?finame:"<stdin>"));
-               }
-       if (fin!=stdin) {
-               chkfclose(fin,finame);
-               free(finame);
+               if (finame) {
+                       chkfclose(fin,finame);
+                       free(finame);
+                       }
                }
 
        for (i=0;i<NELEM(numarg);i++) {
                }
 
        for (i=0;i<NELEM(numarg);i++) {