X-Git-Url: https://git.jankratochvil.net/?p=mdsms.git;a=blobdiff_plain;f=mdsms.c;h=d3f7f74fcd8ffe91c6f25b7826380e41b9f21c42;hp=a630131a73c38d9808e1a5e252518592090b2b0d;hb=52e7876b4289d587a9edb252363691e59fa9e525;hpb=f5a4142536d9895cf78d2e83c1d7ea0391081af0 diff --git a/mdsms.c b/mdsms.c index a630131..d3f7f74 100644 --- a/mdsms.c +++ b/mdsms.c @@ -316,7 +316,8 @@ static const struct option longopts[]={ {"file" ,0,0,'f'}, {"verbose" ,0,0,'v'}, {"help" ,0,0,'h'}, -{"version" ,0,0,'V'}}; +{"version" ,0,0,'V'}, +{NULL ,0,0,0 }}; static void processargs(int argp,char **args,const char *from); @@ -1256,19 +1257,19 @@ long size; #define WORD(n) (((unsigned char)buf[(n)])|(((unsigned char)buf[(n)+1])<<8)) - if (!(f=fopen(logoname,"rb"))) - error(_("^!Cannot open ring file \"%s\" for r/o"),logoname); - if ((size=getfilesize(f,logoname))==-1) + if (!(f=fopen(ringname,"rb"))) + error(_("^!Cannot open ring file \"%s\" for r/o"),ringname); + if ((size=getfilesize(f,ringname))==-1) error(_("!File size determination is essential to continue operation")); if (size<0x103) error(_("!File \"%s\" size %ld too small (must >=0x103)! Is it .000 file?"), - logoname,size); + ringname,size); if (fseek(f,0x100,SEEK_SET)) - error(_("^Seeking error on \"%s\", ignoring"),logoname); + error(_("^Seeking error on \"%s\", ignoring"),ringname); size-=0x100; if (size<=BIN1_PAYLOAD) { if ((got=fread(bin1+7,1,size,f))!=size) - error(_("^Read error on \"%s\", wanted %ld, got %d"),logoname,size,got); + error(_("^Read error on \"%s\", wanted %ld, got %d"),ringname,size,got); error(_("\nSending ring tone \"%s\" as single SMS (size %ld, max %d)"), ringname,size,BIN1_PAYLOAD); nokiaprep(bin1,7+size); @@ -1289,12 +1290,12 @@ long size; binn[11]=fragn; want=MIN(size,BINN_PAYLOAD); if ((got=fread(binn+12,1,want,f))!=want) - error(_("^Read error on \"%s\", wanted %d, got %d"),logoname,want,got); + error(_("^Read error on \"%s\", wanted %d, got %d"),ringname,want,got); nokiaprep(binn,12+want); size-=want; } } - chkfclose(f,logoname); + chkfclose(f,ringname); #undef WORD } @@ -1808,6 +1809,7 @@ int i,cmgf=-1 /* GCC happiness */; unsigned fatal=0; speed_t portbaud=0 /* GCC happiness */; enum modenum argsmode; +unsigned parts=0; if ((s=strrchr((pname=*argv),'/'))) pname=s+1; @@ -2029,11 +2031,12 @@ struct hexdata *hd; restore="\r\nAT+CSMP=17,,0,0"; devcmd(NULL,NULL,"\r\nAT+CSMP=81,,0,245"); - devcmd("\n> ",NULL,"\r\nAT+CMGS=\"%s\"",phone); while ((hd=hexdata)) { + devcmd("\n> ",NULL,"\r\nAT+CMGS=\"%s\"",phone); if (!(s=devcmd(NULL,"\n+CMGS:","!~%s\032",hd->data))) break; - hexdata=hd->next; + if ((hexdata=hd->next)) pushargstack_one(s,0); free(hd); + parts++; } } break; case MODE_RECEIVE: @@ -2079,10 +2082,13 @@ struct hexdata *hd; } if (!s) { retrying(); goto retryall; } - while (isspace(*s)) s++; - if (verbose>=1) error(_("\nMessage successfuly sent with MR (Message Reference): %s"),s); + pushargstack_one(s,0); s=NULL; + if (verbose>=1) while ((s=nextargstack())) { + while (isspace(*s)) s++; + error(_("\nMessage successfuly sent with MR (Message Reference): %s"),s); + } devcmd(NULL,NULL,"\r\nAT"); - logmsg(_("SMS sent (after %d retries), message reference: %s"),retrycnt,s); + logmsg(_("SMS sent (after %d retries), %d part(s)"),retrycnt,parts); return(EXIT_SUCCESS); }