Ajout des snprintf + deplacer la conf dans /etc/
This commit is contained in:
parent
daeecff55c
commit
22f44cc80c
2
README
2
README
|
@ -12,4 +12,4 @@ TODO:
|
||||||
=====
|
=====
|
||||||
|
|
||||||
* non limited numbers
|
* non limited numbers
|
||||||
|
* verify if .conf exists...
|
||||||
|
|
|
@ -74,7 +74,7 @@ int main(void) {
|
||||||
int sock;
|
int sock;
|
||||||
int errsv;
|
int errsv;
|
||||||
|
|
||||||
FILE *conf = fopen("sendsms2mobyt.conf","r");
|
FILE *conf = fopen("/etc/sendsms2mobyt.conf","r");
|
||||||
char line[BUFSIZ];
|
char line[BUFSIZ];
|
||||||
|
|
||||||
char *number1=NULL;
|
char *number1=NULL;
|
||||||
|
@ -163,7 +163,7 @@ int main(void) {
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
|
|
||||||
if (sock == -1) {
|
if (sock == -1) {
|
||||||
sprintf(tmpmsg,"error in socket init: %s\n",strerror(errsv));
|
snprintf(tmpmsg,23+strlen(strerror(errsv)),"error in socket init: %s\n",strerror(errsv));
|
||||||
myerror(tmpmsg);
|
myerror(tmpmsg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ int main(void) {
|
||||||
// TCP connection init
|
// TCP connection init
|
||||||
if (connect(sock,(struct sockaddr *)&sa_in,sizeof(struct sockaddr)) == -1) {
|
if (connect(sock,(struct sockaddr *)&sa_in,sizeof(struct sockaddr)) == -1) {
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
sprintf(tmpmsg,"error in tcp connection init: %s\n",strerror(errsv));
|
snprintf(tmpmsg,33+strlen(strerror(errsv)),"error in tcp connection init: %s\n",strerror(errsv));
|
||||||
myerror(tmpmsg);
|
myerror(tmpmsg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -209,12 +209,11 @@ int main(void) {
|
||||||
subresult = strstr(result,"OK ");
|
subresult = strstr(result,"OK ");
|
||||||
if (subresult) {
|
if (subresult) {
|
||||||
sscanf(subresult,"OK %s",subsubresult);
|
sscanf(subresult,"OK %s",subsubresult);
|
||||||
sprintf(tmpmsg,"send sms with credit %s\n",subsubresult);
|
snprintf(tmpmsg,22+strlen(subsubresult),"send sms with credit %s\n",subsubresult);
|
||||||
syslog(LOG_INFO,tmpmsg);
|
syslog(LOG_INFO,tmpmsg);
|
||||||
} else {
|
} else {
|
||||||
sprintf(tmpmsg,"error while sending");
|
myerror("error while sending");
|
||||||
myerror(tmpmsg);
|
snprintf(tmpmsg,22+strlen(result),"error while sending :\n%s",result);
|
||||||
sprintf(tmpmsg,"error while sending :\n%s",result);
|
|
||||||
errx(1, tmpmsg);
|
errx(1, tmpmsg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue