X-Git-Url: http://git.jankratochvil.net/?p=mdsms.git;a=blobdiff_plain;f=mdsms.c;h=c72614b1d9064ad62e9ef3ce64dba1140094539b;hp=7f5a0e12fe84624aa9b5316388b0c00aca5afaf9;hb=2206dd0220cb009c20c2d83770ae011206b8f011;hpb=bf3bc50c7ef31156f0407c20bd1baa0a002fde5a diff --git a/mdsms.c b/mdsms.c index 7f5a0e1..c72614b 100644 --- a/mdsms.c +++ b/mdsms.c @@ -3,22 +3,6 @@ static char rcsid[] ATTR_UNUSED = "$Id$"; #endif -/* - * $Log$ - * Revision 1.4 1999/07/14 01:01:11 short - * Termios made compatible with Digital UNIX 4.0, cfset[io]speed() missing. - * - * Revision 1.3 1999/06/03 11:46:41 short - * Logging (--log) implemented. - * - * Revision 1.2 1999/06/03 10:38:52 short - * Implemented remaining communication timeouts and maximum retry count. - * - * Revision 1.1.1.1 1999/05/26 13:06:26 short - * First alpha release. - * - */ - #include "setup.h" #include @@ -239,7 +223,7 @@ Usage: " PACKAGE " [-c|--config ] [-d|--device ]\n\ static const struct option longopts[]={ {"config" ,1,0,'c'}, {"device" ,1,0,'d'}, -{"log" ,1,0,'l'}, +{"log" ,1,0,'L'}, {"lockfile",1,0,'l'}, {"smsc" ,1,0,'s'}, {"maxretry",1,0,'m'}, @@ -715,18 +699,19 @@ static char *pdudata; static inline unsigned char charconv(char c,size_t offs) { - if ((c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9')) return(c); switch (c) { case '@': return(0); case '$': return(2); - case '"': return(96); - case ' ': - return(c); case 0: assert(0); + default: + return(c&0x7F); } +#if 0 + if ((c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9')) return(c); error("Can't convert character '%c' (0x%02X) at offs %d (0-based), substituted '?'", c,(unsigned char)c,offs); return('?'); +#endif } static inline void genpdu(void) @@ -827,19 +812,28 @@ char *buf=malloc(l+50); finame=body; body=NULL; } - else fin=stdin; + else { + finame=NULL; + fin=stdin; + } 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:"")); - } - if (fin!=stdin) { - chkfclose(fin,finame); - free(finame); + if (finame) { + chkfclose(fin,finame); + free(finame); + } } for (i=0;i ",NULL,"\r\nAT+CMGS=%d",(strlen(pdusmsc)+strlen(pdudata))/2); - if (!(s=devcmd(NULL,"\n+CMGS:","!%s%s\x1A",pdusmsc,pdudata))) retrying(); + if (!(s=devcmd(NULL,"\n+CMGS:","!%s%s\032",pdusmsc,pdudata))) retrying(); } while (!s); while (isspace(*s)) s++; if (verbose>=1) error("\nMessage successfuly sent with MR: %s",s);