Просмотр исходного кода

sms(s): merge changes from sms(k) (log file refactorings and one security fix)

Henning Westerholt 15 лет назад
Родитель
Сommit
8f52d67376

+ 23 - 28
modules_s/sms/libsms_getsms.c

@@ -53,7 +53,7 @@ mailto:[email protected]
 
 
 
 
 /* converts an octet to a 8-Bit value */
 /* converts an octet to a 8-Bit value */
-int octet2bin(char* octet)
+static inline int octet2bin(char* octet)
 {
 {
 	int result=0;
 	int result=0;
 
 
@@ -74,7 +74,7 @@ int octet2bin(char* octet)
 
 
 /* converts a PDU-String to Ascii; the first octet is the length
 /* converts a PDU-String to Ascii; the first octet is the length
    return the length of ascii */
    return the length of ascii */
-int pdu2ascii(char* pdu, char* ascii)
+static int pdu2ascii(char* pdu, char* ascii)
 {
 {
 	int bitposition=0;
 	int bitposition=0;
 	int byteposition;
 	int byteposition;
@@ -116,7 +116,7 @@ int pdu2ascii(char* pdu, char* ascii)
 
 
 
 
 
 
-int pdu2binary(char* pdu, char* binary)
+static int pdu2binary(char* pdu, char* binary)
 {
 {
 	int count;
 	int count;
 	int octetcounter;
 	int octetcounter;
@@ -134,7 +134,7 @@ int pdu2binary(char* pdu, char* binary)
 /* reads a SMS from the SIM-memory 1-10 */
 /* reads a SMS from the SIM-memory 1-10 */
 /* returns number of SIM memory if successful */
 /* returns number of SIM memory if successful */
 /* on digicom the return value can be != sim */
 /* on digicom the return value can be != sim */
-int fetchsms(struct modem *mdm, int sim, char* pdu)
+static int fetchsms(struct modem *mdm, int sim, char* pdu)
 {
 {
 	char command[16];
 	char command[16];
 	char answer[512];
 	char answer[512];
@@ -156,7 +156,7 @@ int fetchsms(struct modem *mdm, int sim, char* pdu)
 			if (end==position+7) {
 			if (end==position+7) {
 				foo = str2s(position+7,end-position-7,&err);
 				foo = str2s(position+7,end-position-7,&err);
 				if (!err) {
 				if (!err) {
-					DBG("DEBUG:fetchsms:Found a message at memory %i\n",foo);
+					LM_DBG("Found a message at memory %i\n",foo);
 					sim=foo;
 					sim=foo;
 				}
 				}
 				position = 0;
 				position = 0;
@@ -164,7 +164,7 @@ int fetchsms(struct modem *mdm, int sim, char* pdu)
 			position = 0;
 			position = 0;
 		}
 		}
 	} else {
 	} else {
-		DBG("DEBUG:fetchsms:Trying to get stored message %i\n",sim);
+		LM_DBG("Trying to get stored message %i\n",sim);
 		clen=sprintf(command,"AT+CMGR=%i\r",sim);
 		clen=sprintf(command,"AT+CMGR=%i\r",sim);
 		put_command(mdm,command,clen,answer,sizeof(answer),50,0);
 		put_command(mdm,command,clen,answer,sizeof(answer),50,0);
 		/* search for beginning of the answer */
 		/* search for beginning of the answer */
@@ -198,12 +198,12 @@ int fetchsms(struct modem *mdm, int sim, char* pdu)
 
 
 
 
 /* deletes the selected sms from the sim card */
 /* deletes the selected sms from the sim card */
-void deletesms(struct modem *mdm, int sim) {
+static void deletesms(struct modem *mdm, int sim) {
 	char command[32];
 	char command[32];
 	char answer[128];
 	char answer[128];
 	int  clen;
 	int  clen;
 
 
-	DBG("DEBUG:deletesms: Deleting message %i !\n",sim);
+	LM_DBG("Deleting message %i !\n",sim);
 	clen = sprintf(command,"AT+CMGD=%i\r",sim);
 	clen = sprintf(command,"AT+CMGD=%i\r",sim);
 	put_command(mdm, command, clen, answer, sizeof(answer), 50, 0);
 	put_command(mdm, command, clen, answer, sizeof(answer), 50, 0);
 }
 }
@@ -232,8 +232,7 @@ int check_memory(struct modem *mdm, int flag)
 					if (flag==USED_MEM ) {
 					if (flag==USED_MEM ) {
 						foo = str2s(posi,laenge,&err);
 						foo = str2s(posi,laenge,&err);
 						if (err) {
 						if (err) {
-							LOG(L_ERR,"ERROR:sms_check_memory: unable to "
-								"convert into integer used_memory from CPMS"
+							LM_ERR("unable to convert into integer used_memory from CPMS"
 								" response\n");
 								" response\n");
 						} else {
 						} else {
 							return foo;
 							return foo;
@@ -243,8 +242,7 @@ int check_memory(struct modem *mdm, int flag)
 					if ( (laenge=strcspn(posi,",\r"))!=0 ) {
 					if ( (laenge=strcspn(posi,",\r"))!=0 ) {
 						foo = str2s(posi,laenge,&err);
 						foo = str2s(posi,laenge,&err);
 						if (err) {
 						if (err) {
-							LOG(L_ERR,"ERROR:sms_check_memory: unable to"
-								"convert into integer max_memory from CPMS"
+							LM_ERR("unable to convert into integer max_memory from CPMS"
 								" response\n");
 								" response\n");
 						} else {
 						} else {
 							return foo;
 							return foo;
@@ -255,18 +253,15 @@ int check_memory(struct modem *mdm, int flag)
 		} /* if(put_command) */
 		} /* if(put_command) */
 		/* if we are here ->  some error happend */
 		/* if we are here ->  some error happend */
 		if (checkmodem(mdm)!=0) {
 		if (checkmodem(mdm)!=0) {
-			LOG(L_WARN,"WARNING:sms_check_memory: something happend with the"
-				" modem -> was reinit -> let's retry\n");
+			LM_WARN("something happend with the modem -> was reinit -> let's retry\n");
 		} else {
 		} else {
-			LOG(L_ERR,"ERROR:sms_check_memory: modem seems to be ok, but we"
-				"had an error? I give up!\n");
+			LM_ERR("modem seems to be ok, but we had an error? I give up!\n");
 			out = 1;
 			out = 1;
 		}
 		}
 	} /* for */
 	} /* for */
 
 
 	if (out==0)
 	if (out==0)
-		LOG(L_ERR,"ERROR:sms_check_memory: modem does not respond after 10"
-			"reties! I give up :-(\n");
+		LM_ERR("modem does not respond after 10 retries, give up!\n");
 
 
 	return -1;
 	return -1;
 }
 }
@@ -276,7 +271,7 @@ int check_memory(struct modem *mdm, int flag)
 
 
 /* splits an ASCII string into the parts */
 /* splits an ASCII string into the parts */
 /* returns length of ascii */
 /* returns length of ascii */
-int splitascii(struct modem *mdm, char *source, struct incame_sms *sms)
+static int splitascii(struct modem *mdm, char *source, struct incame_sms *sms)
 {
 {
 	char* start;
 	char* start;
 	char* end;
 	char* end;
@@ -333,7 +328,7 @@ int splitascii(struct modem *mdm, char *source, struct incame_sms *sms)
 /* Subroutine for splitpdu() for messages type 0 (SMS-Deliver)
 /* Subroutine for splitpdu() for messages type 0 (SMS-Deliver)
    Returns the length of the ascii string
    Returns the length of the ascii string
    In binary mode ascii contains the binary SMS */
    In binary mode ascii contains the binary SMS */
-int split_type_0( char* Pointer,struct incame_sms *sms)
+static int split_type_0( char* Pointer,struct incame_sms *sms)
 {
 {
 	int Length;
 	int Length;
 	int padding;
 	int padding;
@@ -366,7 +361,7 @@ int split_type_0( char* Pointer,struct incame_sms *sms)
 /* Subroutine for splitpdu() for messages type 2 (Staus Report)
 /* Subroutine for splitpdu() for messages type 2 (Staus Report)
    Returns the length of the ascii string. In binary mode ascii 
    Returns the length of the ascii string. In binary mode ascii 
    contains the binary SMS */
    contains the binary SMS */
-int split_type_2( char* position, struct incame_sms *sms)
+static int split_type_2( char* position, struct incame_sms *sms)
 {
 {
 	int  length;
 	int  length;
 	int  padding;
 	int  padding;
@@ -407,7 +402,7 @@ int split_type_2( char* position, struct incame_sms *sms)
 
 
 /* Splits a PDU string into the parts */
 /* Splits a PDU string into the parts */
 /* Returns the length of the ascii string. In binary mode ascii contains the binary SMS */
 /* Returns the length of the ascii string. In binary mode ascii contains the binary SMS */
-int splitpdu(struct modem *mdm, char* pdu, struct incame_sms *sms)
+static int splitpdu(struct modem *mdm, char* pdu, struct incame_sms *sms)
 {
 {
 	int Length;
 	int Length;
 	int Type;
 	int Type;
@@ -468,7 +463,7 @@ int splitpdu(struct modem *mdm, char* pdu, struct incame_sms *sms)
 
 
 
 
 
 
-inline int decode_pdu( struct modem *mdm, char *pdu, struct incame_sms *sms)
+static inline int decode_pdu( struct modem *mdm, char *pdu, struct incame_sms *sms)
 {
 {
 	int ret;
 	int ret;
 
 
@@ -480,7 +475,7 @@ inline int decode_pdu( struct modem *mdm, char *pdu, struct incame_sms *sms)
 		ret = splitpdu(mdm, pdu, sms);
 		ret = splitpdu(mdm, pdu, sms);
 
 
 	if (ret==-1) {
 	if (ret==-1) {
-		LOG(L_ERR,"ERROR:decode_pdu: unable split pdu/ascii!\n");
+		LM_ERR("unable split pdu/ascii!\n");
 		return -1;
 		return -1;
 	}
 	}
 	return 1;
 	return 1;
@@ -491,13 +486,13 @@ inline int decode_pdu( struct modem *mdm, char *pdu, struct incame_sms *sms)
 
 
 int getsms( struct incame_sms *sms, struct modem *mdm, int sim)
 int getsms( struct incame_sms *sms, struct modem *mdm, int sim)
 {
 {
-	char   pdu[500];
+	char   pdu[512];
 	int    found;
 	int    found;
 	int    ret;
 	int    ret;
 
 
 	found = fetchsms(mdm,sim,pdu);
 	found = fetchsms(mdm,sim,pdu);
 	if ( !found ) {
 	if ( !found ) {
-		LOG(L_ERR,"ERROR:getsms: unable to fetch sms %d!\n",sim);
+		LM_ERR("unable to fetch sms %d!\n",sim);
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -524,14 +519,14 @@ int cds2sms(struct incame_sms *sms, struct modem *mdm, char *s, int s_len)
 	ptr = s;
 	ptr = s;
 	for ( n=0 ; n<2 && (ptr=strstr(ptr,"\r\n")) ; n++,ptr+=2 );
 	for ( n=0 ; n<2 && (ptr=strstr(ptr,"\r\n")) ; n++,ptr+=2 );
 	if (n<2) {
 	if (n<2) {
-		LOG(L_ERR,"ERROR:cds2sms: cannot find pdu begining in CDS!\n");
+		LM_ERR("failed to find pdu begining in CDS!\n");
 		goto error;
 		goto error;
 	}
 	}
 	data = ptr;
 	data = ptr;
 
 
 	/* pdu end with "\r\n" */
 	/* pdu end with "\r\n" */
 	if (!(ptr=strstr(data,"\r\n"))) {
 	if (!(ptr=strstr(data,"\r\n"))) {
-		LOG(L_ERR,"ERROR:cds2sms: cannot find pdu end in CDS!\n");
+		LM_ERR("failed to find pdu end in CDS!\n");
 		goto error;
 		goto error;
 		}
 		}
 	tmp = ptr[0];
 	tmp = ptr[0];

+ 29 - 40
modules_s/sms/libsms_modem.c

@@ -66,12 +66,12 @@ int put_command( struct modem *mdm, char* cmd, int cmd_len, char* answer,
 		timeoutcounter++;
 		timeoutcounter++;
 		ioctl(mdm->fd,TIOCMGET,&status);
 		ioctl(mdm->fd,TIOCMGET,&status);
 		if (timeoutcounter>=timeout) {
 		if (timeoutcounter>=timeout) {
-			LOG(L_INFO,"INFO:put_command: Modem is not clear to send\n");
+			LM_INFO("Modem is not clear to send\n");
 			return 0;
 			return 0;
 		}
 		}
 	}
 	}
 #ifdef SHOW_SMS_MODEM_COMMAND
 #ifdef SHOW_SMS_MODEM_COMMAND
-	DBG("DEBUG: put_command: -<%d>-->[%.*s] \n",cmd_len,cmd_len,cmd);
+	LM_DBG("-<%d>-->[%.*s] \n",cmd_len,cmd_len,cmd);
 #endif
 #endif
 	/* send the command to the modem */
 	/* send the command to the modem */
 	write(mdm->fd,cmd,cmd_len);
 	write(mdm->fd,cmd,cmd_len);
@@ -101,20 +101,19 @@ int put_command( struct modem *mdm, char* cmd, int cmd_len, char* answer,
 			/* read data */
 			/* read data */
 			n = read( mdm->fd, buf+buf_len, n);
 			n = read( mdm->fd, buf+buf_len, n);
 			if (n<0) {
 			if (n<0) {
-				LOG(L_ERR,"ERROR:put_command: error reading from modem: %s\n",
-					strerror(errno));
+				LM_ERR("error reading from modem: %s\n", strerror(errno));
 				goto error;
 				goto error;
 			}
 			}
 			if (n) {
 			if (n) {
 				buf_len += n;
 				buf_len += n;
 				buf[buf_len] = 0;
 				buf[buf_len] = 0;
-				//DBG("DEBUG:put_commnad: read = [%s]\n",buf+buf_len-n);
+				//LM_DBG("read = [%s]\n",buf+buf_len-n);
 				foo = pos = 0;
 				foo = pos = 0;
 				if ( (!exp_end && ((pos=strstr(optz(n,4),"OK\r\n"))
 				if ( (!exp_end && ((pos=strstr(optz(n,4),"OK\r\n"))
 				|| (foo=strstr(optz(n,5),"ERROR"))))
 				|| (foo=strstr(optz(n,5),"ERROR"))))
 				|| (exp_end && (pos=strstr(optz(n,exp_end_len),exp_end)) )) {
 				|| (exp_end && (pos=strstr(optz(n,exp_end_len),exp_end)) )) {
 					/* we found the end */
 					/* we found the end */
-					//DBG("DEBUG:put_commnad: end found = %s\n",
+					//LM_DBG("end found = %s\n",
 					//	(foo?"ERROR":(exp_end?exp_end:"OK")));
 					//	(foo?"ERROR":(exp_end?exp_end:"OK")));
 					/* for ERROR we still have to read EOL */
 					/* for ERROR we still have to read EOL */
 					if (!foo || (foo=strstr(foo+5,"\r\n"))) {
 					if (!foo || (foo=strstr(foo+5,"\r\n"))) {
@@ -143,12 +142,12 @@ int put_command( struct modem *mdm, char* cmd, int cmd_len, char* answer,
 			ptr = pos+CDS_HDR_LEN;
 			ptr = pos+CDS_HDR_LEN;
 			for( n=0 ; n<2&&(foo=strstr(ptr,"\r\n")) ; ptr=foo+2,n++ );
 			for( n=0 ; n<2&&(foo=strstr(ptr,"\r\n")) ; ptr=foo+2,n++ );
 			if (n<2) { /* we haven't read the entire CDS response */
 			if (n<2) { /* we haven't read the entire CDS response */
-				DBG("DEBUG:put_command: CDS end not found!\n");
+				LM_DBG("CDS end not found!\n");
 				to_move = pos;
 				to_move = pos;
 				ptr = buf + buf_len;
 				ptr = buf + buf_len;
 			}else{
 			}else{
 				/* process the CDS */
 				/* process the CDS */
-				DBG("DEBUG:put_command:CDS=[%.*s]\n",(int)(ptr-pos),pos);
+				LM_DBG("CDS=[%.*s]\n",(int)(ptr-pos),pos);
 				cds_report_func(mdm,pos,ptr-pos);
 				cds_report_func(mdm,pos,ptr-pos);
 			}
 			}
 		}
 		}
@@ -171,13 +170,13 @@ int put_command( struct modem *mdm, char* cmd, int cmd_len, char* answer,
 		buf_len = buf_len - (to_move-buf);
 		buf_len = buf_len - (to_move-buf);
 		memcpy(buf,to_move,buf_len);
 		memcpy(buf,to_move,buf_len);
 		buf[buf_len] = 0;
 		buf[buf_len] = 0;
-		DBG("DEBUG:put_commnad: buffer shifted left=[%d][%s]\n",buf_len,buf);
+		LM_DBG("buffer shifted left=[%d][%s]\n",buf_len,buf);
 	} else {
 	} else {
 		buf_len = 0;
 		buf_len = 0;
 	}
 	}
 
 
 #ifdef SHOW_SMS_MODEM_COMMAND
 #ifdef SHOW_SMS_MODEM_COMMAND
-	DBG("DEBUG:put_command: <-[%s] \n",answer);
+	LM_DBG("<-[%s] \n",answer);
 #endif
 #endif
 	return answer_e-answer_s;
 	return answer_e-answer_s;
 
 
@@ -219,30 +218,28 @@ int initmodem(struct modem *mdm, cds_report cds_report_f)
 	int clen=0;
 	int clen=0;
 	int n;
 	int n;
 
 
-	LOG(L_INFO,"INFO:initmodem: init modem %s on %s.\n",mdm->name,mdm->device);
+	LM_INFO("init modem %s on %s.\n",mdm->name,mdm->device);
 
 
 	if (mdm->pin[0]) {
 	if (mdm->pin[0]) {
 		/* Checking if modem needs PIN */
 		/* Checking if modem needs PIN */
 		put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 		put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 		if (strstr(answer,"+CPIN: SIM PIN")) {
 		if (strstr(answer,"+CPIN: SIM PIN")) {
-			LOG(L_INFO,"INFO:initmodem: Modem needs PIN, entering PIN...\n");
+			LM_INFO("Modem needs PIN, entering PIN...\n");
 			clen=sprintf(command,"AT+CPIN=\"%s\"\r",mdm->pin);
 			clen=sprintf(command,"AT+CPIN=\"%s\"\r",mdm->pin);
 			put_command(mdm,command,clen,answer,sizeof(answer),100,0);
 			put_command(mdm,command,clen,answer,sizeof(answer),100,0);
 			put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 			put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 			if (!strstr(answer,"+CPIN: READY")) {
 			if (!strstr(answer,"+CPIN: READY")) {
 				if (strstr(answer,"+CPIN: SIM PIN")) {
 				if (strstr(answer,"+CPIN: SIM PIN")) {
-					LOG(L_ERR,"ERROR:initmodem: Modem did not accept"
-						" this PIN\n");
+					LM_ERR("Modem did not accept this PIN\n");
 					goto error;
 					goto error;
 				} else if (strstr(answer,"+CPIN: SIM PUK")) {
 				} else if (strstr(answer,"+CPIN: SIM PUK")) {
-					LOG(L_ERR,"ERROR:initmodem: YourPIN is locked!"
-						" Unlock it manually!\n");
+					LM_ERR("YourPIN is locked! Unlock it manually!\n");
 					goto error;
 					goto error;
 				} else {
 				} else {
 					goto error;
 					goto error;
 				}
 				}
 			}
 			}
-			LOG(L_INFO,"INFO:initmodem: PIN Ready!\n");
+			LM_INFO("PIN Ready!\n");
 			sleep(5);
 			sleep(5);
 		}
 		}
 	}
 	}
@@ -250,8 +247,7 @@ int initmodem(struct modem *mdm, cds_report cds_report_f)
 	if (mdm->mode==MODE_DIGICOM)
 	if (mdm->mode==MODE_DIGICOM)
 		success=1;
 		success=1;
 	else {
 	else {
-		LOG(L_INFO,"INFO:initmodem: Checking if Modem is registered to"
-			" the network\n");
+		LM_INFO("Checking if Modem is registered to the network\n");
 		success=0;
 		success=0;
 		retries=0;
 		retries=0;
 		do
 		do
@@ -260,34 +256,30 @@ int initmodem(struct modem *mdm, cds_report cds_report_f)
 			put_command(mdm,"AT+CREG?\r",9,answer,sizeof(answer),100,0);
 			put_command(mdm,"AT+CREG?\r",9,answer,sizeof(answer),100,0);
 			if (strchr(answer,'1') )
 			if (strchr(answer,'1') )
 			{
 			{
-				LOG(L_INFO,"INFO:initmodem: Modem is registered to the"
-					" network\n");
+				LM_INFO("Modem is registered to the network\n");
 				success=1;
 				success=1;
 			} else if (strchr(answer,'2')) {
 			} else if (strchr(answer,'2')) {
 				// added by bogdan
 				// added by bogdan
-				LOG(L_WARN,"WARNING:initmodem: Modems seems to try to "
-					"reach the network! Let's wait a little bit\n");
+				LM_WARN("Modems seems to try to reach the network!"
+						" Let's wait a little bit\n");
 				retries--;
 				retries--;
 				sleep(2);
 				sleep(2);
 			} else if (strchr(answer,'5')) {
 			} else if (strchr(answer,'5')) {
 				// added by Thomas Stoeckel
 				// added by Thomas Stoeckel
-				LOG(L_INFO,"INFO:initmodem: Modem is registered to a"
-					" roaming partner network\n");
+				LM_INFO("Modem is registered to a roaming partner network\n");
 				success=1;
 				success=1;
 			} else if (strstr(answer,"ERROR")) {
 			} else if (strstr(answer,"ERROR")) {
-				LOG(L_WARN,"WARNING:initmodem: Ignoring that modem does"
-					" not support +CREG command.\n");
+				LM_WARN("Ignoring that modem does not support +CREG command.\n");
 				success=1;
 				success=1;
 			} else {
 			} else {
-				LOG(L_NOTICE,"NOTICE:initmodem: Waiting 2 sec. before"
-					" retrying\n");
+				LM_NOTICE("Waiting 2 sec. before retrying\n");
 				sleep(2);
 				sleep(2);
 			}
 			}
 		}while ((success==0)&&(retries<20));
 		}while ((success==0)&&(retries<20));
 	}
 	}
 
 
 	if (success==0) {
 	if (success==0) {
-		LOG(L_ERR,"ERROR:initmodem: Modem is not registered to the network\n");
+		LM_ERR("Modem is not registered to the network\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
@@ -321,28 +313,26 @@ int initmodem(struct modem *mdm, cds_report cds_report_f)
 			put_command(mdm,command,clen,answer,sizeof(answer),100,0);
 			put_command(mdm,command,clen,answer,sizeof(answer),100,0);
 			/*dealing with the answer*/
 			/*dealing with the answer*/
 			if (strstr(answer,"ERROR")) {
 			if (strstr(answer,"ERROR")) {
-				LOG(L_NOTICE,"NOTICE:initmodem: Waiting 1 sec. before to"
-					" retrying\n");
+				LM_NOTICE("Waiting 1 sec. before to retrying\n");
 				sleep(1);
 				sleep(1);
 			} else
 			} else
 				success=1;
 				success=1;
 		}while ((success==0)&&(retries<3));
 		}while ((success==0)&&(retries<3));
 		/* have we succeeded? */
 		/* have we succeeded? */
 		if (success==0) {
 		if (success==0) {
-			LOG(L_ERR,"ERROR:initmodem: cmd [%.*s] returned ERROR\n",
-				clen-1,command);
+			LM_ERR("cmd [%.*s] returned ERROR\n", clen-1,command);
 			goto error;
 			goto error;
 		}
 		}
 	} /* end for */
 	} /* end for */
 
 
 	if ( sms_report_type==CDS_REPORT && !cds_report_f) {
 	if ( sms_report_type==CDS_REPORT && !cds_report_f) {
-		LOG(L_ERR,"ERROR:initmodem:no CDS_REPORT function given\n");
+		LM_ERR("no CDS_REPORT function given\n");
 		goto error;
 		goto error;
 	}
 	}
 	cds_report_func = cds_report_f;
 	cds_report_func = cds_report_f;
 
 
 	if (mdm->smsc[0]) {
 	if (mdm->smsc[0]) {
-		LOG(L_INFO,"INFO:initmodem: Changing SMSC to \"%s\"\n",mdm->smsc);
+		LM_INFO("Changing SMSC to \"%s\"\n",mdm->smsc);
 		setsmsc(mdm,mdm->smsc);
 		setsmsc(mdm,mdm->smsc);
 	}
 	}
 
 
@@ -363,22 +353,21 @@ int checkmodem(struct modem *mdm)
 	/* Checking if modem needs PIN */
 	/* Checking if modem needs PIN */
 	put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 	put_command(mdm,"AT+CPIN?\r",9,answer,sizeof(answer),50,0);
 	if (!strstr(answer,"+CPIN: READY")) {
 	if (!strstr(answer,"+CPIN: READY")) {
-		LOG(L_WARN,"WARNING:sms_checkmodem: modem wants the PIN again!\n");
+		LM_WARN("modem wants the PIN again!\n");
 		goto reinit;
 		goto reinit;
 	}
 	}
 
 
 	if (mdm->mode!=MODE_DIGICOM) {
 	if (mdm->mode!=MODE_DIGICOM) {
 		put_command(mdm,"AT+CREG?\r",9,answer,sizeof(answer),100,0);
 		put_command(mdm,"AT+CREG?\r",9,answer,sizeof(answer),100,0);
 		if (!strchr(answer,'1') ) {
 		if (!strchr(answer,'1') ) {
-			LOG(L_WARN,"WARNING:sms_checkmodem: Modem is not registered to the"
-					" network\n");
+			LM_WARN("Modem is not registered to the network\n");
 			goto reinit;
 			goto reinit;
 		}
 		}
 	}
 	}
 
 
 	return 1;
 	return 1;
 reinit:
 reinit:
-	LOG(L_WARN,"WARNING:sms_checkmodem: re -init the modem!!\n");
+	LM_WARN("re -init the modem!!\n");
 	initmodem(mdm,cds_report_func);
 	initmodem(mdm,cds_report_func);
 	return -1;
 	return -1;
 }
 }

+ 4 - 5
modules_s/sms/libsms_putsms.c

@@ -230,20 +230,19 @@ int putsms( struct sms_msg *sms_messg, struct modem *mdm)
 			/* we have an error */
 			/* we have an error */
 			if (checkmodem(mdm)==-1) {
 			if (checkmodem(mdm)==-1) {
 				err_code = 0;
 				err_code = 0;
-				LOG(L_WARN,"WARNING: putsms: resending last sms! \n");
+				LM_WARN("resending last sms! \n");
 			} else if (err_code==0) {
 			} else if (err_code==0) {
-				LOG(L_WARN,"WARNING: putsms :possible corrupted sms."
-					" Let's try again!\n");
+				LM_WARN("possible corrupted sms. Let's try again!\n");
 				err_code = 1;
 				err_code = 1;
 			}else {
 			}else {
-				LOG(L_ERR,"ERROR: We have a FUBAR sms!! drop it!\n");
+				LM_ERR("We have a FUBAR sms!! drop it!\n");
 				err_code = 3;
 				err_code = 3;
 			}
 			}
 		}
 		}
 	}
 	}
 
 
 	if (err_code==0)
 	if (err_code==0)
-		LOG(L_WARN,"WARNING: something spooky is going on with the modem!"
+		LM_WARN("something spooky is going on with the modem!"
 			" Re-inited and re-tried for %d times without success!\n",
 			" Re-inited and re-tried for %d times without success!\n",
 			mdm->retry);
 			mdm->retry);
 	return (err_code==0?-2:(err_code==2?sms_id:-1));
 	return (err_code==0?-2:(err_code==2?sms_id:-1));

+ 41 - 57
modules_s/sms/sms.c

@@ -133,8 +133,7 @@ static int fixup_sms_send_msg_to_net(void** param, int param_no)
 			if (!strcasecmp(networks[i].name,*param))
 			if (!strcasecmp(networks[i].name,*param))
 				net_nr = i;
 				net_nr = i;
 		if (net_nr==-1) {
 		if (net_nr==-1) {
-			LOG(L_ERR,"ERROR:fixup_sms_send_msg_to_net: network \"%s\""
-				" not found in net list!\n",(char*)*param);
+			LM_ERR("network \"%s\" not found in net list!\n",(char*)*param);
 			return E_UNSPEC;
 			return E_UNSPEC;
 		} else {
 		} else {
 			pkg_free(*param);
 			pkg_free(*param);
@@ -161,7 +160,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 	int err, foo;
 	int err, foo;
 
 
 	if (*(arg+1)!='=') {
 	if (*(arg+1)!='=') {
-		LOG(L_ERR,"ERROR: invalid parameter syntax near [=]\n");
+		LM_ERR("invalid parameter syntax near [=]\n");
 		goto error;
 		goto error;
 	}
 	}
 	switch (*arg)
 	switch (*arg)
@@ -188,7 +187,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 			&& arg_end-arg-2==3) {
 			&& arg_end-arg-2==3) {
 				mdm->mode = MODE_NEW;
 				mdm->mode = MODE_NEW;
 			} else {
 			} else {
-				LOG(L_ERR,"ERROR: invalid value \"%.*s\" for param [m]\n",
+				LM_ERR("invalid value \"%.*s\" for param [m]\n",
 					(int)(arg_end-arg-2),arg+2);
 					(int)(arg_end-arg-2),arg+2);
 				goto error;
 				goto error;
 			}
 			}
@@ -200,8 +199,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 		case 'r':  /* retry time */
 		case 'r':  /* retry time */
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			if (err) {
 			if (err) {
-				LOG(L_ERR,"ERROR:set_modem_arg: cannot convert [r] arg to"
-					" integer!\n");
+				LM_ERR("failed to convert [r] arg to integer!\n");
 				goto error;
 				goto error;
 			}
 			}
 			mdm->retry = foo;
 			mdm->retry = foo;
@@ -209,8 +207,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 		case 'l':  /* looping interval */
 		case 'l':  /* looping interval */
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			if (err) {
 			if (err) {
-				LOG(L_ERR,"ERROR:set_modem_arg: cannot convert [l] arg to"
-					" integer!\n");
+				LM_ERR("failed to convert [l] arg to integer!\n");
 				goto error;
 				goto error;
 			}
 			}
 			mdm->looping_interval = foo;
 			mdm->looping_interval = foo;
@@ -218,8 +215,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 		case 'b':  /* baudrate */
 		case 'b':  /* baudrate */
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			if (err) {
 			if (err) {
-				LOG(L_ERR,"ERROR:set_modem_arg: cannot convert [b] arg to"
-					" integer!\n");
+				LM_ERR("failed to convert [b] arg to integer!\n");
 				goto error;
 				goto error;
 			}
 			}
 			switch (foo) {
 			switch (foo) {
@@ -231,8 +227,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 				case 38400: foo=B38400; break;
 				case 38400: foo=B38400; break;
 				case 57600: foo=B57600; break;
 				case 57600: foo=B57600; break;
 				default:
 				default:
-					LOG(L_ERR,"ERROR:set_modem_arg: unsupported value %d "
-						"for [b] arg!\n",foo);
+					LM_ERR("unsupported value %d for [b] arg!\n",foo);
 					goto error;
 					goto error;
 			}
 			}
 			mdm->baudrate = foo;
 			mdm->baudrate = foo;
@@ -240,8 +235,8 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 		case 's':  /* scan */
 		case 's':  /* scan */
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			if (err) {
 			if (err) {
-				LOG(L_WARN,"WARNING:set_modem_arg: cannot convert [s] arg to"
-					" integer!, assume default mode s=%d (SCAN)\n",SMS_BODY_SCAN);
+				LM_WARN("cannot convert [s] arg to integer!, assume default mode s=%d (SCAN)\n", 
+					SMS_BODY_SCAN);
 				foo = SMS_BODY_SCAN;
 				foo = SMS_BODY_SCAN;
 			}
 			}
 			switch (foo) {
 			switch (foo) {
@@ -250,8 +245,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 				case   SMS_BODY_SCAN_MIX: 
 				case   SMS_BODY_SCAN_MIX: 
 					break;
 					break;
 				default:
 				default:
-					LOG(L_WARN,"WARNING:set_modem_arg: unsupported value s=%d "
-						  "for [s] arg!, assume default mode s=%d (SCAN)\n",
+					LM_WARN("unsupported value s=%d for [s] arg!, assume default mode s=%d (SCAN)\n",
 						  foo,SMS_BODY_SCAN);
 						  foo,SMS_BODY_SCAN);
 					foo = SMS_BODY_SCAN;
 					foo = SMS_BODY_SCAN;
 			}
 			}
@@ -262,7 +256,7 @@ int set_modem_arg(struct modem *mdm, char *arg, char *arg_end)
 			mdm->to[arg_end-arg-2] = 0;
 			mdm->to[arg_end-arg-2] = 0;
 			break;
 			break;
 		default:
 		default:
-			LOG(L_ERR,"ERROR:set_modem_arg: unknown param name [%c]\n",*arg);
+			LM_ERR("unknown param name [%c]\n",*arg);
 			goto error;
 			goto error;
 	}
 	}
 
 
@@ -279,7 +273,7 @@ int set_network_arg(struct network *net, char *arg, char *arg_end)
 	int err,foo;
 	int err,foo;
 
 
 	if (*(arg+1)!='=') {
 	if (*(arg+1)!='=') {
-		LOG(L_ERR,"ERROR:set_network_arg:invalid parameter syntax near [=]\n");
+		LM_ERR("invalid parameter syntax near [=]\n");
 		goto error;
 		goto error;
 	}
 	}
 	switch (*arg)
 	switch (*arg)
@@ -287,14 +281,13 @@ int set_network_arg(struct network *net, char *arg, char *arg_end)
 		case 'm':  /* maximum sms per one call */
 		case 'm':  /* maximum sms per one call */
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			foo=str2s(arg+2,arg_end-arg-2,&err);
 			if (err) {
 			if (err) {
-				LOG(L_ERR,"ERROR:set_network_arg: cannot convert [m] arg to"
-					" integer!\n");
+				LM_ERR("cannot convert [m] arg to integer!\n");
 				goto error;
 				goto error;
 			}
 			}
 			net->max_sms_per_call = foo;
 			net->max_sms_per_call = foo;
 			break;
 			break;
 		default:
 		default:
-			LOG(L_ERR,"ERROR:set_network_arg: unknown param name [%c]\n",*arg);
+			LM_ERR("unknown param name [%c]\n",*arg);
 			goto error;
 			goto error;
 	}
 	}
 
 
@@ -306,7 +299,7 @@ error:
 
 
 
 
 
 
-int parse_config_lines()
+int parse_config_lines(void)
 {
 {
 	char *p,*start;
 	char *p,*start;
 	int  i, k, step;
 	int  i, k, step;
@@ -318,8 +311,7 @@ int parse_config_lines()
 	step = 1;
 	step = 1;
 	/* parsing modems configuration string */
 	/* parsing modems configuration string */
 	if ( (p = modems_config)==0) {
 	if ( (p = modems_config)==0) {
-		LOG(L_ERR,"ERROR:SMS parse_config_lines: param \"modems\" not"
-			" found\n");
+		LM_ERR("param \"modems\" not found\n");
 		goto error;
 		goto error;
 	}
 	}
 	while (*p)
 	while (*p)
@@ -370,14 +362,13 @@ int parse_config_lines()
 		p++;
 		p++;
 		/* end of element */
 		/* end of element */
 		if (modems[nr_of_modems].device[0]==0) {
 		if (modems[nr_of_modems].device[0]==0) {
-			LOG(L_ERR,"ERROR:SMS parse config modems: modem %s has no device"
-				" associated\n",modems[nr_of_modems].name);
+			LM_ERR("modem %s has no device associated\n",
+					modems[nr_of_modems].name);
 			goto error;
 			goto error;
 		}
 		}
 		if (modems[nr_of_modems].smsc[0]==0) {
 		if (modems[nr_of_modems].smsc[0]==0) {
-			LOG(L_WARN,"WARNING:SMS parse config modem: modem %s has no sms"
-				" center associated -> using the default one from modem\n",
-				modems[nr_of_modems].name);
+			LM_WARN("modem %s has no sms center associated -> using"
+				" the default one from modem\n",modems[nr_of_modems].name);
 		}
 		}
 		nr_of_modems++;
 		nr_of_modems++;
 		eat_spaces(p);
 		eat_spaces(p);
@@ -388,15 +379,14 @@ int parse_config_lines()
 	}
 	}
 	if (nr_of_modems==0)
 	if (nr_of_modems==0)
 	{
 	{
-		LOG(L_ERR,"ERROR:SMS parse config modems - no modem found!\n");
+		LM_ERR("failed to parse config modems - no modem found!\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	step++;
 	step++;
 	/* parsing networks configuration string */
 	/* parsing networks configuration string */
 	if ( (p = networks_config)==0) {
 	if ( (p = networks_config)==0) {
-		LOG(L_ERR,"ERROR:SMS parse_config_lines: param \"networks\" not "
-			"found\n");
+		LM_ERR("param \"networks\" not found\n");
 		goto error;
 		goto error;
 	}
 	}
 	while (*p)
 	while (*p)
@@ -444,15 +434,14 @@ int parse_config_lines()
 	}
 	}
 	if (nr_of_networks==0)
 	if (nr_of_networks==0)
 	{
 	{
-		LOG(L_ERR,"ERROR:SMS parse config networks - no network found!\n");
+		LM_ERR("no network found!\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	step++;
 	step++;
 	/* parsing links configuration string */
 	/* parsing links configuration string */
 	if ( (p = links_config)==0) {
 	if ( (p = links_config)==0) {
-		LOG(L_ERR,"ERROR:SMS parse_config_lines: param \"links\" not "
-			"found\n");
+		LM_ERR("param \"links\" not found\n");
 		goto error;
 		goto error;
 	}
 	}
 	while (*p)
 	while (*p)
@@ -470,8 +459,7 @@ int parse_config_lines()
 			modems[i].name[p-start]==0)
 			modems[i].name[p-start]==0)
 				mdm_nr = i;
 				mdm_nr = i;
 		if (mdm_nr==-1) {
 		if (mdm_nr==-1) {
-			LOG(L_ERR,"ERROR:sms_parse_conf_line: unknown modem %.*s \n,",
-				(int)(p-start), start);
+			LM_ERR("unknown modem %.*s \n,",(int)(p-start), start);
 			goto error;
 			goto error;
 		}
 		}
 		/*get associated networks list*/
 		/*get associated networks list*/
@@ -494,13 +482,12 @@ int parse_config_lines()
 				&& networks[i].name[p-start]==0)
 				&& networks[i].name[p-start]==0)
 					net_nr = i;
 					net_nr = i;
 			if (net_nr==-1) {
 			if (net_nr==-1) {
-				LOG(L_ERR,"ERROR:SMS parse modem config - associated"
-					" net <%.*s> not found in net list\n",
+				LM_ERR("associated net <%.*s> not found in net list\n",
 					(int)(p-start), start);
 					(int)(p-start), start);
 				goto error;
 				goto error;
 			}
 			}
-			DBG("DEBUG:sms startup: linking net \"%s\" to modem \"%s\" on "
-				"pos %d.\n",networks[net_nr].name,modems[mdm_nr].name,k);
+			LM_DBG("linking net \"%s\" to modem \"%s\" on pos %d.\n",
+					networks[net_nr].name,modems[mdm_nr].name,k);
 			modems[mdm_nr].net_list[k++]=net_nr;
 			modems[mdm_nr].net_list[k++]=net_nr;
 			eat_spaces(p);
 			eat_spaces(p);
 			if (*p==';') {
 			if (*p==';') {
@@ -525,8 +512,7 @@ int parse_config_lines()
 			if (!strcasecmp(networks[i].name,default_net_str))
 			if (!strcasecmp(networks[i].name,default_net_str))
 				net_nr = i;
 				net_nr = i;
 		if (net_nr==-1) {
 		if (net_nr==-1) {
-			LOG(L_ERR,"ERROR:SMS setting default net: network \"%s\""
-				" not found in net list!\n",default_net_str);
+			LM_ERR("network \"%s\" not found in net list!\n",default_net_str);
 			goto error;
 			goto error;
 		}
 		}
 		default_net = net_nr;
 		default_net = net_nr;
@@ -534,7 +520,7 @@ int parse_config_lines()
 
 
 	return 0;
 	return 0;
 parse_error:
 parse_error:
-	LOG(L_ERR,"ERROR: SMS %s config: parse error before  chr %d [%.*s]\n",
+	LM_ERR("SMS %s config: parse error before  chr %d [%.*s]\n",
 		(step==1)?"modems":(step==2?"networks":"links"),
 		(step==1)?"modems":(step==2?"networks":"links"),
 		(int)(p - ((step==1)?modems_config:
 		(int)(p - ((step==1)?modems_config:
 				   (step==2?networks_config:links_config))),
 				   (step==2?networks_config:links_config))),
@@ -546,7 +532,7 @@ error:
 
 
 
 
 
 
-int global_init()
+int global_init(void)
 {
 {
 	load_tm_f  load_tm;
 	load_tm_f  load_tm;
 	int        i, net_pipe[2], foo;
 	int        i, net_pipe[2], foo;
@@ -555,7 +541,7 @@ int global_init()
 
 
 	/* import the TM auto-loading function */
 	/* import the TM auto-loading function */
 	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {
 	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {
-		LOG(L_ERR, "ERROR: sms: global_init: cannot import load_tm\n");
+		LM_ERR("cannot import load_tm\n");
 		goto error;
 		goto error;
 	}
 	}
 	/* let the auto-loading function load all TM stuff */
 	/* let the auto-loading function load all TM stuff */
@@ -569,7 +555,7 @@ int global_init()
 	} else {
 	} else {
 		si=get_first_socket();
 		si=get_first_socket();
 		if (si==0){
 		if (si==0){
-			LOG(L_CRIT, "BUG: sms_init_child: null listen socket list\n");
+			LM_CRIT("null listen socket list\n");
 			goto error;
 			goto error;
 		}
 		}
 		/*do I have to add port?*/
 		/*do I have to add port?*/
@@ -577,7 +563,7 @@ int global_init()
 		domain.len = si->name.len + i*(si->port_no_str.len+1);
 		domain.len = si->name.len + i*(si->port_no_str.len+1);
 		domain.s = (char*)pkg_malloc(domain.len);
 		domain.s = (char*)pkg_malloc(domain.len);
 		if (!domain.s) {
 		if (!domain.s) {
-			LOG(L_ERR,"ERROR:sms_init_child: no free pkg memory!\n");
+			LM_ERR("no free pkg memory!\n");
 			goto error;
 			goto error;
 		}
 		}
 		p = domain.s;
 		p = domain.s;
@@ -595,35 +581,33 @@ int global_init()
 	{
 	{
 		/* create the pipe*/
 		/* create the pipe*/
 		if (pipe(net_pipe)==-1) {
 		if (pipe(net_pipe)==-1) {
-			LOG(L_ERR,"ERROR: sms_global_init: cannot create pipe!\n");
+			LM_ERR("failed to create pipe!\n");
 			goto error;
 			goto error;
 		}
 		}
 		networks[i].pipe_out = net_pipe[0];
 		networks[i].pipe_out = net_pipe[0];
 		net_pipes_in[i] = net_pipe[1];
 		net_pipes_in[i] = net_pipe[1];
 		/* sets reading from pipe to non blocking */
 		/* sets reading from pipe to non blocking */
 		if ((foo=fcntl(net_pipe[0],F_GETFL,0))<0) {
 		if ((foo=fcntl(net_pipe[0],F_GETFL,0))<0) {
-			LOG(L_ERR,"ERROR: sms_global_init: cannot get flag for pipe"
-				" - fcntl\n");
+			LM_ERR("failed to get flag for pipe - fcntl\n");
 			goto error;
 			goto error;
 		}
 		}
 		foo |= O_NONBLOCK;
 		foo |= O_NONBLOCK;
 		if (fcntl(net_pipe[0],F_SETFL,foo)<0) {
 		if (fcntl(net_pipe[0],F_SETFL,foo)<0) {
-			LOG(L_ERR,"ERROR: sms_global_init: cannot set flag for pipe"
-				" - fcntl\n");
+			LM_ERR("failed to set flag for pipe - fcntl\n");
 			goto error;
 			goto error;
 		}
 		}
 	}
 	}
 
 
 	/* if report will be used, init the report queue */
 	/* if report will be used, init the report queue */
 	if (sms_report_type!=NO_REPORT && !init_report_queue()) {
 	if (sms_report_type!=NO_REPORT && !init_report_queue()) {
-		LOG(L_ERR,"ERROR: sms_global_init: cannot get shm memory!\n");
+		LM_ERR("cannot get shm memory!\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	/* alloc in shm for queued_msgs */
 	/* alloc in shm for queued_msgs */
 	queued_msgs = (int*)shm_malloc(sizeof(int));
 	queued_msgs = (int*)shm_malloc(sizeof(int));
 	if (!queued_msgs) {
 	if (!queued_msgs) {
-		LOG(L_ERR,"ERROR: sms_global_init: cannot get shm memory!\n");
+		LM_ERR("cannot get shm memory!\n");
 		goto error;
 		goto error;
 	}
 	}
 	*queued_msgs = 0;
 	*queued_msgs = 0;
@@ -651,7 +635,7 @@ int sms_child_init(int rank)
 	for(i=0;i<nr_of_modems;i++)
 	for(i=0;i<nr_of_modems;i++)
 	{
 	{
 		if ( (foo=fork())<0 ) {
 		if ( (foo=fork())<0 ) {
-			LOG(L_ERR,"ERROR: sms_child_init: cannot fork \n");
+			LM_ERR("cannot fork \n");
 			goto error;
 			goto error;
 		}
 		}
 		if (!foo) {
 		if (!foo) {
@@ -674,7 +658,7 @@ error:
 
 
 static int sms_init(void)
 static int sms_init(void)
 {
 {
-	LOG(L_INFO,"SMS - initializing\n");
+	LM_INFO("SMS - initializing\n");
 
 
 	if (parse_config_lines()==-1)
 	if (parse_config_lines()==-1)
 		return -1;
 		return -1;

+ 53 - 61
modules_s/sms/sms_funcs.c

@@ -121,7 +121,7 @@ inline int add_contact(struct sip_msg* msg , str* user)
 
 
 	buf = pkg_malloc( len );
 	buf = pkg_malloc( len );
 	if(!buf) {
 	if(!buf) {
-		LOG(L_ERR,"ERROR:sms_add_contact: out of memory! \n");
+		LM_ERR("out of memory! \n");
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -136,7 +136,7 @@ inline int add_contact(struct sip_msg* msg , str* user)
 
 
 	lump = build_lump_rpl( buf , len , LUMP_RPL_HDR);
 	lump = build_lump_rpl( buf , len , LUMP_RPL_HDR);
 	if(!lump) {
 	if(!lump) {
-		LOG(L_ERR,"ERROR:sms_add_contact: unable to build lump_rpl! \n");
+		LM_ERR("unable to build lump_rpl! \n");
 		pkg_free( buf );
 		pkg_free( buf );
 		return -1;
 		return -1;
 	}
 	}
@@ -165,28 +165,28 @@ int push_on_network(struct sip_msg *msg, int net)
 	 * calls of parse_headers function for FROM, CONTENT_LENGTH, TO hdrs  */
 	 * calls of parse_headers function for FROM, CONTENT_LENGTH, TO hdrs  */
 	body.s = get_body( msg );
 	body.s = get_body( msg );
 	if (body.s==0) {
 	if (body.s==0) {
-		LOG(L_ERR,"ERROR:sms_push_on_net: cannot extract body from msg!\n");
+		LM_ERR("failed to extract body from msg!\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	/* content-length (if present) must be already parsed */
 	/* content-length (if present) must be already parsed */
 	if (!msg->content_length) {
 	if (!msg->content_length) {
-		LOG(L_ERR,"ERROR:sms_push_on_net: no Content-Length header found!\n");
+		LM_ERR("no Content-Length header found!\n");
 		goto error;
 		goto error;
 	}
 	}
 	body.len = get_content_length( msg );
 	body.len = get_content_length( msg );
 
 
 	/* parse the content-type header */
 	/* parse the content-type header */
 	if ( (mime=parse_content_type_hdr(msg))<1 ) {
 	if ( (mime=parse_content_type_hdr(msg))<1 ) {
-		LOG(L_ERR,"ERROR:sms_push_on_net:cannot parse Content-Type header\n");
+		LM_ERR("failed to parse Content-Type header\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	/* check the content-type value */
 	/* check the content-type value */
 	if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
 	if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
 	&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {
 	&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {
-		LOG(L_ERR,"ERROR:sms_push_on_net: invalid content-type for a "
-			"message request! type found=%d\n",mime);
+		LM_ERR("invalid content-type for a message request! type found=%d\n",
+				mime);
 		goto error;
 		goto error;
 	}
 	}
 
 
@@ -195,22 +195,21 @@ int push_on_network(struct sip_msg *msg, int net)
 	   if it's missing there (like in requests generated by MSN MESSENGER),
 	   if it's missing there (like in requests generated by MSN MESSENGER),
 	   we go for "to" header
 	   we go for "to" header
 	*/
 	*/
-	DBG("DEBUG:sms_push_on_net: string to get user from new_uri\n");
+	LM_DBG("string to get user from new_uri\n");
 	if ( !msg->new_uri.s||parse_uri( msg->new_uri.s,msg->new_uri.len,&uri)
 	if ( !msg->new_uri.s||parse_uri( msg->new_uri.s,msg->new_uri.len,&uri)
 	|| !uri.user.len )
 	|| !uri.user.len )
 	{
 	{
-		DBG("DEBUG:sms_push_on_net: string to get user from R_uri\n");
+		LM_DBG("string to get user from R_uri\n");
 		if ( parse_uri( msg->first_line.u.request.uri.s,
 		if ( parse_uri( msg->first_line.u.request.uri.s,
 		msg->first_line.u.request.uri.len ,&uri)||!uri.user.len )
 		msg->first_line.u.request.uri.len ,&uri)||!uri.user.len )
 		{
 		{
-			DBG("DEBUG:sms_push_on_net: string to get user from To\n");
+			LM_DBG("string to get user from To\n");
 			if ( (!msg->to&&((parse_headers(msg,HDR_TO_F,0)==-1) ||
 			if ( (!msg->to&&((parse_headers(msg,HDR_TO_F,0)==-1) ||
 					!msg->to)) ||
 					!msg->to)) ||
 				parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
 				parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
 			|| !uri.user.len)
 			|| !uri.user.len)
 			{
 			{
-				LOG(L_ERR,"ERROR:sms_push_on_net: unable to extract user"
-					" name from RURI and To header!\n");
+				LM_ERR("unable to extract user name from RURI and To header!\n");
 				goto error;
 				goto error;
 			}
 			}
 		}
 		}
@@ -218,14 +217,14 @@ int push_on_network(struct sip_msg *msg, int net)
 	/* check the uri.user format = '+(inter code)(number)' */
 	/* check the uri.user format = '+(inter code)(number)' */
 	if (uri.user.len<2 || uri.user.s[0]!='+' || uri.user.s[1]<'1'
 	if (uri.user.len<2 || uri.user.s[0]!='+' || uri.user.s[1]<'1'
 	|| uri.user.s[1]>'9') {
 	|| uri.user.s[1]>'9') {
-		LOG(L_ERR,"ERROR:sms_push_on_net: user tel number [%.*s] does not"
-			"respect international format\n",uri.user.len,uri.user.s);
+		LM_ERR("user tel number [%.*s] does not respect international format\n"
+				,uri.user.len,uri.user.s);
 		goto error;
 		goto error;
 	}
 	}
 
 
 	/* parsing from header */
 	/* parsing from header */
 	if ( parse_from_header( msg )==-1 ) {
 	if ( parse_from_header( msg )==-1 ) {
-		LOG(L_ERR,"ERROR:sms_push_on_net: cannot get FROM header\n");
+		LM_ERR("failed to get FROM header\n");
 		goto error;
 		goto error;
 	}
 	}
 	from = (struct to_body*)msg->from->parsed;
 	from = (struct to_body*)msg->from->parsed;
@@ -233,7 +232,7 @@ int push_on_network(struct sip_msg *msg, int net)
 #if 0
 #if 0
 	/* adds contact header into reply */
 	/* adds contact header into reply */
 	if (add_contact(msg,&(uri.user))==-1) {
 	if (add_contact(msg,&(uri.user))==-1) {
-		LOG(L_ERR,"ERROR:sms_push_on_net:can't build contact for reply\n");
+		LM_ERR("can't build contact for reply\n");
 		goto error;
 		goto error;
 	}
 	}
 #endif
 #endif
@@ -248,7 +247,7 @@ int push_on_network(struct sip_msg *msg, int net)
 	/* allocs a new sms_msg structure in shared memory */
 	/* allocs a new sms_msg structure in shared memory */
 	sms_messg = (struct sms_msg*)shm_malloc(len);
 	sms_messg = (struct sms_msg*)shm_malloc(len);
 	if (!sms_messg) {
 	if (!sms_messg) {
-		LOG(L_ERR,"ERROR:sms_push_on_net: cannot get shm memory!\n");
+		LM_ERR("failed to get shm memory!\n");
 		goto error;
 		goto error;
 	}
 	}
 	p = (char*)sms_messg + sizeof(struct sms_msg);
 	p = (char*)sms_messg + sizeof(struct sms_msg);
@@ -280,8 +279,8 @@ int push_on_network(struct sip_msg *msg, int net)
 	if (write(net_pipes_in[net], &sms_messg, sizeof(sms_messg))!=
 	if (write(net_pipes_in[net], &sms_messg, sizeof(sms_messg))!=
 	sizeof(sms_messg) )
 	sizeof(sms_messg) )
 	{
 	{
-		LOG(L_ERR,"ERROR:sms_push_on_net: error when writing for net %d "
-			"to pipe [%d] : %s\n",net,net_pipes_in[net],strerror(errno) );
+		LM_ERR("error when writing for net %d to pipe [%d] : %s\n",
+				net,net_pipes_in[net],strerror(errno) );
 		shm_free(sms_messg);
 		shm_free(sms_messg);
 		(*queued_msgs)--;
 		(*queued_msgs)--;
 		goto error;
 		goto error;
@@ -303,7 +302,7 @@ int send_sip_msg_request(str *to, str *from_user, str *body)
 	str hdrs;
 	str hdrs;
 	int foo;
 	int foo;
 	char *p;
 	char *p;
-	uac_req_t	uac_r;
+	uac_req_t uac_r;
 
 
 	from.s = hdrs.s = 0;
 	from.s = hdrs.s = 0;
 	from.len = hdrs.len = 0;
 	from.len = hdrs.len = 0;
@@ -363,7 +362,7 @@ int send_sip_msg_request(str *to, str *from_user, str *body)
 	if (hdrs.s) pkg_free(hdrs.s);
 	if (hdrs.s) pkg_free(hdrs.s);
 	return foo;
 	return foo;
 error:
 error:
-	LOG(L_ERR,"ERROR:sms_build_and_send_sip: no free pkg memory!\n");
+	LM_ERR("no free pkg memory!\n");
 	if (from.s) pkg_free(from.s);
 	if (from.s) pkg_free(from.s);
 	if (hdrs.s) pkg_free(hdrs.s);
 	if (hdrs.s) pkg_free(hdrs.s);
 	return -1;
 	return -1;
@@ -393,7 +392,7 @@ inline int send_error(struct sms_msg *sms_messg, char *msg1_s, int msg1_len,
 	pkg_free( body.s );
 	pkg_free( body.s );
 	return foo;
 	return foo;
 error:
 error:
-	LOG(L_ERR,"ERROR:sms_send_error: no free pkg memory!\n");
+	LM_ERR("no free pkg memory!\n");
 	return -1;
 	return -1;
 
 
 }
 }
@@ -500,7 +499,7 @@ int send_as_sms(struct sms_msg *sms_messg, struct modem *mdm)
 			send_error(sms_messg, ERR_TRUNCATE_TEXT, ERR_TRUNCATE_TEXT_LEN,
 			send_error(sms_messg, ERR_TRUNCATE_TEXT, ERR_TRUNCATE_TEXT_LEN,
 				p, text.len-(p-text.s)-SMS_FOOTER_LEN);
 				p, text.len-(p-text.s)-SMS_FOOTER_LEN);
 		}
 		}
-		DBG("---%d--<%d><%d>--\n|%.*s|\n", i, len_array[i], buf_len,
+		LM_DBG("---%d--<%d><%d>--\n|%.*s|\n", i, len_array[i], buf_len,
 										(int)buf_len, buf);
 										(int)buf_len, buf);
 		sms_messg->text.s   = buf;
 		sms_messg->text.s   = buf;
 		sms_messg->text.len = buf_len;
 		sms_messg->text.len = buf_len;
@@ -581,16 +580,15 @@ int send_sms_as_sip( struct incame_sms *sms )
 				p++;
 				p++;
 			p++;
 			p++;
 			if (p+9>=sms->ascii+sms->userdatalength) {
 			if (p+9>=sms->ascii+sms->userdatalength) {
-				LOG(L_ERR,"ERROR:send_sms_as_sip: unable to find sip_address"
-					" start in sms body [%s]!\n",sms->ascii);
+				LM_ERR("unable to find sip_address start in sms body [%s]!\n",
+						sms->ascii);
 				goto error;
 				goto error;
 			}
 			}
 			
 			
 		}
 		}
 		/* lets get the address */
 		/* lets get the address */
 		if (p[0]!='s' || p[1]!='i' || p[2]!='p' || p[3]!=':') {
 		if (p[0]!='s' || p[1]!='i' || p[2]!='p' || p[3]!=':') {
-			LOG(L_ERR,"ERROR:send_sms_as_sip: wrong sip address format in"
-				" sms body [%s]!\n",sms->ascii);
+			LM_ERR("wrong sip address format in sms body [%s]!\n",sms->ascii);
 			goto error;
 			goto error;
 		}
 		}
 		sip_addr.s = p;
 		sip_addr.s = p;
@@ -598,11 +596,11 @@ int send_sms_as_sip( struct incame_sms *sms )
 		while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
 		while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
 			p++;
 			p++;
 		if (p>=sms->ascii+sms->userdatalength) {
 		if (p>=sms->ascii+sms->userdatalength) {
-			LOG(L_ERR,"ERROR:send_sms_as_sip: cannot find sip address end in"
-				"sms body [%s]!\n",sms->ascii);
+			LM_ERR("failed to find sip address end in sms body [%s]!\n",
+					sms->ascii);
 		}
 		}
 		sip_addr.len = p-sip_addr.s;
 		sip_addr.len = p-sip_addr.s;
-		DBG("DEBUG:send_sms_as_sip: sip address found [%.*s]\n",
+		LM_DBG("sip address found [%.*s]\n",
 			sip_addr.len,sip_addr.s);
 			sip_addr.len,sip_addr.s);
 		/* try to match SMS_HDR_AF_ADDR */
 		/* try to match SMS_HDR_AF_ADDR */
 		k=0;
 		k=0;
@@ -621,24 +619,24 @@ int send_sms_as_sip( struct incame_sms *sms )
 				while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
 				while(p<sms->ascii+sms->userdatalength && is_in_sip_addr(*p) )
 					p++;
 					p++;
 				if (p==sms->ascii+sms->userdatalength) {
 				if (p==sms->ascii+sms->userdatalength) {
-					LOG(L_ERR,"ERROR:send_sms_as_sip: cannot find sip"
-						" address end in sms body [%s]!\n",sms->ascii);
+					LM_ERR("failed to find sip address end in sms body [%s]!\n",
+							sms->ascii);
 					goto error;
 					goto error;
 				}
 				}
 				sip_addr.len = p-sip_addr.s;
 				sip_addr.len = p-sip_addr.s;
 			} else {
 			} else {
 				/* parse to the next word */
 				/* parse to the next word */
-				/*DBG("*** Skipping word len=%d\n",sms->userdatalength);*/
+				/*LM_DBG("*** Skipping word len=%d\n",sms->userdatalength);*/
 				while(p<sms->ascii+sms->userdatalength&&no_sip_addr_begin(*p)){
 				while(p<sms->ascii+sms->userdatalength&&no_sip_addr_begin(*p)){
 					p++;
 					p++;
 				}
 				}
 				p++;
 				p++;
 				if (p+9>=sms->ascii+sms->userdatalength) {
 				if (p+9>=sms->ascii+sms->userdatalength) {
-				LOG(L_ERR,"ERROR:send_sms_as_sip: unable to find sip "
-						"address start in sms body [%s]!\n",sms->ascii);
+				LM_ERR("unable to find sip address start in sms body [%s]!\n",
+						sms->ascii);
 					goto error;
 					goto error;
 				}
 				}
-				/*DBG("*** Done\n");*/
+				/*LM_DBG("*** Done\n");*/
 			}
 			}
 		}while (!sip_addr.len);
 		}while (!sip_addr.len);
 	}
 	}
@@ -653,12 +651,10 @@ int send_sms_as_sip( struct incame_sms *sms )
 		sip_body.len--;
 		sip_body.len--;
 	}
 	}
 	if (sip_body.len==0) {
 	if (sip_body.len==0) {
-		LOG(L_WARN,"WARNING:send_sms_as_sip: empty body for sms [%s]",
-			sms->ascii);
+		LM_WARN("empty body for sms [%s]", sms->ascii);
 		goto error;
 		goto error;
 	}
 	}
-	DBG("DEBUG:send_sms_as_sip: extracted body is: [%.*s]\n",
-		sip_body.len, sip_body.s);
+	LM_DBG("extracted body is: [%.*s]\n",sip_body.len, sip_body.s);
 
 
 	/* finally, let's send it as sip message */
 	/* finally, let's send it as sip message */
 	sip_from.s = sms->sender;
 	sip_from.s = sms->sender;
@@ -711,8 +707,7 @@ int send_sms_as_sip_scan_no(struct incame_sms *sms, char *to)
 	}
 	}
 
 
 	if (sip_body.len == 0) {
 	if (sip_body.len == 0) {
-		LOG(L_WARN,"WARNING:send_sms_as_sip_scan_no: SMS empty body "
-			"for sms [%s]\n",sms->ascii);
+		LM_WARN("SMS empty body for sms [%s]\n",sms->ascii);
 		goto error;
 		goto error;
 	}
 	}
 
 
@@ -729,7 +724,7 @@ int send_sms_as_sip_scan_no(struct incame_sms *sms, char *to)
 		sip_body.len += CRLF_LEN + DATE_LEN + TIME_LEN + 3;
 		sip_body.len += CRLF_LEN + DATE_LEN + TIME_LEN + 3;
 	}
 	}
 
 
-	DBG("DEBUG:send_sms_as_sip_scan_no: SMS from: [%.*s], to: [%.*s], body: [%.*s]\n",
+	LM_DBG("SMS from: [%.*s], to: [%.*s], body: [%.*s]\n",
 		sip_from.len, sip_from.s, sip_to.len, sip_to.s, sip_body.len, sip_body.s);
 		sip_from.len, sip_from.s, sip_to.len, sip_to.s, sip_body.len, sip_body.s);
 
 
 	/* finally, let's send it as sip message */
 	/* finally, let's send it as sip message */
@@ -761,7 +756,7 @@ int _send_sms_as_sip(struct incame_sms *sms, struct modem *mdm)
 	}
 	}
 	
 	
 	/* CASE IMPOSIBLE!!!!, scan assume default value SMS_BODY_SCAN */
 	/* CASE IMPOSIBLE!!!!, scan assume default value SMS_BODY_SCAN */
-	LOG(L_ERR,"ERROR:_send_sms_as_sip: SMS bad config param scan: %d for modem: %s\n",
+	LM_ERR("SMS bad config param scan: %d for modem: %s\n",
 		mdm->scan, mdm->name);
 		mdm->scan, mdm->name);
 
 
 	return -1;
 	return -1;
@@ -776,7 +771,7 @@ int check_sms_report( struct incame_sms *sms )
 	int old;
 	int old;
 	int res;
 	int res;
 
 
-	DBG("DEBUG:sms:check_sms_report: Report for sms number %d.\n",sms->sms_id);
+	LM_DBG("Report for sms number %d.\n",sms->sms_id);
 	res=relay_report_to_queue( sms->sms_id, sms->sender, sms->ascii[0], &old);
 	res=relay_report_to_queue( sms->sms_id, sms->sender, sms->ascii[0], &old);
 	if (res==3) { /* error */
 	if (res==3) { /* error */
 		/* the sms was confirmed with an error code -> we have to send a
 		/* the sms was confirmed with an error code -> we have to send a
@@ -836,10 +831,10 @@ void modem_process(struct modem *mdm)
 	cpms_unsuported = 0;
 	cpms_unsuported = 0;
 
 
 	/* let's open/init the modem */
 	/* let's open/init the modem */
-	DBG("DEBUG:modem_process: opening modem\n");
+	LM_DBG("opening modem\n");
 	if (openmodem(mdm)==-1) {
 	if (openmodem(mdm)==-1) {
-		LOG(L_ERR,"ERROR:modem_process: cannot open modem %s!"
-			" %s \n",mdm->name,strerror(errno));
+		LM_ERR("failed to open modem %s! %s \n",
+			mdm->name,strerror(errno));
 		return;
 		return;
 	}
 	}
 
 
@@ -847,12 +842,11 @@ void modem_process(struct modem *mdm)
 	initmodem(mdm,check_cds_report);
 	initmodem(mdm,check_cds_report);
 
 
 	if ( (max_mem=check_memory(mdm,MAX_MEM))==-1 ) {
 	if ( (max_mem=check_memory(mdm,MAX_MEM))==-1 ) {
-		LOG(L_WARN,"WARNING:modem_process: CPMS command unsuported!"
-			" using default values (10,10)\n");
+		LM_WARN("CPMS command unsuported! using default values (10,10)\n");
 		used_mem = max_mem = 10;
 		used_mem = max_mem = 10;
 		cpms_unsuported = 1;
 		cpms_unsuported = 1;
 	}
 	}
-	DBG("DEBUG:modem_process: modem maximum memory is %d\n",max_mem);
+	LM_DBG("modem maximum memory is %d\n",max_mem);
 
 
 	set_gettime_function();
 	set_gettime_function();
 
 
@@ -875,13 +869,12 @@ void modem_process(struct modem *mdm)
 					sizeof(sms_messg));
 					sizeof(sms_messg));
 				if (len!=sizeof(sms_messg)) {
 				if (len!=sizeof(sms_messg)) {
 					if (len>=0)
 					if (len>=0)
-						LOG(L_ERR,"ERROR:modem_process: truncated message"
-						" read from pipe! -> discarded\n");
+						LM_ERR("truncated message read from pipe!"
+								" -> discarded\n");
 					else if (errno==EAGAIN)
 					else if (errno==EAGAIN)
 						empty_pipe = 1;
 						empty_pipe = 1;
 					else
 					else
-						LOG(L_ERR,"ERROR:modem_process: pipe reading failed: "
-							" : %s\n",strerror(errno));
+						LM_ERR("pipe reading failed: %s\n",strerror(errno));
 					sleep(1);
 					sleep(1);
 					counter++;
 					counter++;
 					continue;
 					continue;
@@ -889,7 +882,7 @@ void modem_process(struct modem *mdm)
 				(*queued_msgs)--;
 				(*queued_msgs)--;
 
 
 				/* compute and send the sms */
 				/* compute and send the sms */
-				DBG("DEBUG:modem_process: %s processing sms for net %s:"
+				LM_DBG("%s processing sms for net %s:"
 					" \n\tTo:[%.*s]\n\tBody=<%d>[%.*s]\n",
 					" \n\tTo:[%.*s]\n\tBody=<%d>[%.*s]\n",
 					mdm->device, net->name,
 					mdm->device, net->name,
 					sms_messg->to.len,sms_messg->to.s,
 					sms_messg->to.len,sms_messg->to.s,
@@ -906,20 +899,19 @@ void modem_process(struct modem *mdm)
 		/* let's see if we have incoming sms */
 		/* let's see if we have incoming sms */
 		if ( !cpms_unsuported )
 		if ( !cpms_unsuported )
 			if ((used_mem = check_memory(mdm,USED_MEM))==-1) {
 			if ((used_mem = check_memory(mdm,USED_MEM))==-1) {
-				LOG(L_ERR,"ERROR:modem_process: CPMS command failed!"
-					" cannot get used mem -> using 10\n");
+				LM_ERR("CPMS command failed! cannot get used mem -> using 10\n");
 				used_mem = 10;
 				used_mem = 10;
 			}
 			}
 
 
 		/* if any, let's get them */
 		/* if any, let's get them */
 		if (used_mem)
 		if (used_mem)
-			DBG("DEBUG:modem_process: %d new SMS on modem\n",used_mem);
+			LM_DBG("%d new SMS on modem\n",used_mem);
 			for(i=1,k=1;k<=used_mem && i<=max_mem;i++) {
 			for(i=1,k=1;k<=used_mem && i<=max_mem;i++) {
 				if (getsms(&sms,mdm,i)!=-1) {
 				if (getsms(&sms,mdm,i)!=-1) {
 					k++;
 					k++;
-					DBG("SMS Get from location %d\n",i);
+					LM_DBG("SMS Get from location %d\n",i);
 					/*for test ;-) ->  to be remove*/
 					/*for test ;-) ->  to be remove*/
-					DBG("SMS RECEIVED:\n\rFrom: %s %s\n\r%.*s %.*s"
+					LM_DBG("SMS RECEIVED:\n\rFrom: %s %s\n\r%.*s %.*s"
 						"\n\r\"%.*s\"\n\r",sms.sender,sms.name,
 						"\n\r\"%.*s\"\n\r",sms.sender,sms.name,
 						DATE_LEN,sms.date,TIME_LEN,sms.time,
 						DATE_LEN,sms.date,TIME_LEN,sms.time,
 						sms.userdatalength,sms.ascii);
 						sms.userdatalength,sms.ascii);

+ 18 - 21
modules_s/sms/sms_report.c

@@ -93,7 +93,7 @@ static time_t get_time_sys(void)
 }
 }
 /* detects if the ser time function get_ticks works, and depending of that
 /* detects if the ser time function get_ticks works, and depending of that
    sets the correct time function to be used */
    sets the correct time function to be used */
-void set_gettime_function()
+void set_gettime_function(void)
 {
 {
 	unsigned int t1,t2;
 	unsigned int t1,t2;
 
 
@@ -102,10 +102,10 @@ void set_gettime_function()
 	t2 = get_ticks();
 	t2 = get_ticks();
 	if (!t1 && !t2) {
 	if (!t1 && !t2) {
 		get_time = get_time_sys;
 		get_time = get_time_sys;
-		LOG(L_INFO,"INFO:sms:set_gettime_function: using system time func.\n");
+		LM_INFO("using system time func.\n");
 	} else {
 	} else {
 		get_time = get_time_ser;
 		get_time = get_time_ser;
-		LOG(L_INFO,"INFO:sms:set_gettime_function: using ser time func.\n");
+		LM_INFO("using ser time func.\n");
 	}
 	}
 }
 }
 
 
@@ -128,12 +128,12 @@ inline void free_report_cell(struct report_cell *cell)
 
 
 
 
 
 
-int init_report_queue()
+int init_report_queue(void)
 {
 {
 	report_queue = (struct report_cell*)
 	report_queue = (struct report_cell*)
 		shm_malloc(NR_CELLS*sizeof(struct report_cell));
 		shm_malloc(NR_CELLS*sizeof(struct report_cell));
 	if (!report_queue) {
 	if (!report_queue) {
-		LOG(L_ERR,"ERROR:sms:init_report_queue: no more free pkg_mem!\n");
+		LM_ERR("no more free pkg_mem!\n");
 		return -1;
 		return -1;
 	}
 	}
 	memset( report_queue , 0 , NR_CELLS*sizeof(struct report_cell) );
 	memset( report_queue , 0 , NR_CELLS*sizeof(struct report_cell) );
@@ -143,7 +143,7 @@ int init_report_queue()
 
 
 
 
 
 
-void destroy_report_queue()
+void destroy_report_queue(void)
 {
 {
 	int i;
 	int i;
 
 
@@ -162,8 +162,8 @@ void destroy_report_queue()
 void add_sms_into_report_queue(int id, struct sms_msg *sms, char *p, int l)
 void add_sms_into_report_queue(int id, struct sms_msg *sms, char *p, int l)
 {
 {
 	if (report_queue[id].sms){
 	if (report_queue[id].sms){
-		LOG(L_INFO,"INFO:sms:add_sms_into_report_queue: old message still "
-			"waiting for report at location %d -> discarding\n",id);
+		LM_INFO("old message still waiting for report at location %d"
+				" -> discarding\n",id);
 		free_report_cell(&(report_queue[id]));
 		free_report_cell(&(report_queue[id]));
 	}
 	}
 
 
@@ -188,14 +188,14 @@ int  relay_report_to_queue(int id, char *phone, int status, int *old_status)
 
 
 	/* first, do we have a match into the sms queue? */
 	/* first, do we have a match into the sms queue? */
 	if (!cell->sms) {
 	if (!cell->sms) {
-		LOG(L_INFO,"INFO:sms:relay_report_to_queue: report received for cell"
-			" %d,  but the sms was already trashed from queue!\n",id);
+		LM_INFO("report received for cell %d,"
+				" but the sms was already trashed from queue!\n",id);
 		goto done;
 		goto done;
 	}
 	}
 	if (strlen(phone)!=cell->sms->to.len ||
 	if (strlen(phone)!=cell->sms->to.len ||
 	strncmp(phone,cell->sms->to.s,cell->sms->to.len)) {
 	strncmp(phone,cell->sms->to.s,cell->sms->to.len)) {
-		LOG(L_INFO,"INFO:sms:relay_report_to_queue: report received for cell"
-			" %d, but the phone nr is different->old report->ignored\n",id);
+		LM_INFO("report received for cell %d, but the phone nr is different"
+				"->old report->ignored\n",id);
 		goto done;
 		goto done;
 	}
 	}
 
 
@@ -203,17 +203,15 @@ int  relay_report_to_queue(int id, char *phone, int status, int *old_status)
 		*old_status = cell->status;
 		*old_status = cell->status;
 	cell->status = status;
 	cell->status = status;
 	if (status>=0 && status<32) {
 	if (status>=0 && status<32) {
-		DBG("DEBUG:sms:relay_report_to_queue:sms %d confirmed with code %d\n",
-			id, status);
+		LM_DBG("sms %d confirmed with code %d\n", id, status);
 		ret_code = 2; /* success */
 		ret_code = 2; /* success */
 	} else if (status<64) {
 	} else if (status<64) {
 		/* provisional report */
 		/* provisional report */
-		DBG("DEBUG:sms:relay_report_to_queue:sms %d received prov. report with"
+		LM_DBG("sms %d received prov. report with"
 			" code %d\n",id, status);
 			" code %d\n",id, status);
 		ret_code = 1; /* provisional */
 		ret_code = 1; /* provisional */
 	} else {
 	} else {
-		DBG("DEBUG:sms:relay_report_to_queue:sms %d received error report with"
-			" code %d\n",id, status);
+		LM_DBG("sms %d received error report with code %d\n",id, status);
 		ret_code = 3; /* error */
 		ret_code = 3; /* error */
 	}
 	}
 
 
@@ -224,7 +222,7 @@ done:
 
 
 
 
 
 
-void check_timeout_in_report_queue()
+void check_timeout_in_report_queue(void)
 {
 {
 	int i;
 	int i;
 	time_t current_time;
 	time_t current_time;
@@ -232,9 +230,8 @@ void check_timeout_in_report_queue()
 	current_time = get_time();
 	current_time = get_time();
 	for(i=0;i<NR_CELLS;i++)
 	for(i=0;i<NR_CELLS;i++)
 		if (report_queue[i].sms && report_queue[i].timeout<=current_time) {
 		if (report_queue[i].sms && report_queue[i].timeout<=current_time) {
-			LOG(L_INFO,"INFO:sms:check_timeout_in_report_queue: [%lu,%lu] "
-				"record %d is discarded (timeout), having status %d\n",
-				(long unsigned int)current_time,
+			LM_INFO("[%lu,%lu] record %d is discarded (timeout), having status"
+				" %d\n", (long unsigned int)current_time,
 				(long unsigned int)report_queue[i].timeout,
 				(long unsigned int)report_queue[i].timeout,
 				i,report_queue[i].status);
 				i,report_queue[i].status);
 			free_report_cell(&(report_queue[i]));
 			free_report_cell(&(report_queue[i]));

+ 4 - 4
modules_s/sms/sms_report.h

@@ -34,16 +34,16 @@
 #define NR_CELLS  256
 #define NR_CELLS  256
 
 
 
 
-int    init_report_queue();
-void   destroy_report_queue();
+int    init_report_queue(void);
+void   destroy_report_queue(void);
 void   add_sms_into_report_queue(int id, struct sms_msg *sms, char *, int );
 void   add_sms_into_report_queue(int id, struct sms_msg *sms, char *, int );
 int    relay_report_to_queue(int id, char *phone, int status, int *old_status);
 int    relay_report_to_queue(int id, char *phone, int status, int *old_status);
-void   check_timeout_in_report_queue();
+void   check_timeout_in_report_queue(void);
 str*   get_error_str(int status);
 str*   get_error_str(int status);
 void   remove_sms_from_report_queue(int id);
 void   remove_sms_from_report_queue(int id);
 str*   get_text_from_report_queue(int id);
 str*   get_text_from_report_queue(int id);
 struct sms_msg* get_sms_from_report_queue(int id);
 struct sms_msg* get_sms_from_report_queue(int id);
-void   set_gettime_function();
+void   set_gettime_function(void);
 
 
 
 
 #endif
 #endif