Re: variable, shouldn't, be, named, sms

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

seems your patch doesn't do what you describe. see below...

Thanks,
Alex

Wilfried Goesgens schrieb:
> If one wants to compare to the messagetype 'sms', naming a variable 'sms' causes nameclashes.
> 
> This Patch shouldn't introduce any new features asside renaming 'sms' to 'msg' as it is called in most other places.
> 
> Kind Regards, 
> 
> Wilfried G�sgens
> 
> 
> ------------------------------------------------------------------------
> 
> --- a/gateway/gw/bb_smscconn.c	2005-11-10 17:17:10.000000000 +0100
> +++ b/gateway/gw/bb_smscconn.c	2006-04-05 19:30:42.000000000 +0200
>  
> -long bb_smscconn_receive(SMSCConn *conn, Msg *sms)
> +long bb_smscconn_receive(SMSCConn *conn, Msg *msg)
>  {
>      char *uf;
>      int rc;
>      Msg *copy;
> +	long CSMRN, TOTAL, SEQUENCE;

what is that?

>  
>     /*
>      * First normalize in smsc level and then on global level.
>      * In outbound direction it's vise versa, hence first global then smsc.
>      */
>      uf = (conn && conn->unified_prefix) ? octstr_get_cstr(conn->unified_prefix) : NULL;
> -    normalize_number(uf, &(sms->sms.sender));
> +    normalize_number(uf, &(msg->sms.sender));
>  
>      uf = unified_prefix ? octstr_get_cstr(unified_prefix) : NULL;
> -    normalize_number(uf, &(sms->sms.sender));
> +    normalize_number(uf, &(msg->sms.sender));
>  
>      if (white_list &&
> -	numhash_find_number(white_list, sms->sms.sender) < 1) {
> +	numhash_find_number(white_list, msg->sms.sender) < 1) {
>  	info(0, "Number <%s> is not in white-list, message discarded",
> -	     octstr_get_cstr(sms->sms.sender));
> -	bb_alog_sms(conn, sms, "REJECTED - not white-listed SMS");
> -	msg_destroy(sms);
> +	     octstr_get_cstr(msg->sms.sender));
> +	bb_alog_sms(conn, msg, "REJECTED - not white-listed SMS");
> +	msg_destroy(msg);
>          return SMSCCONN_FAILED_REJECTED;
>      }
>  
> -    if (white_list_regex && (gw_regex_matches(white_list_regex, sms->sms.sender) == NO_MATCH)) {
> +    if (white_list_regex && (gw_regex_matches(white_list_regex, msg->sms.sender) == NO_MATCH)) {
>          info(0, "Number <%s> is not in white-list, message discarded",
> -             octstr_get_cstr(sms->sms.sender));
> -        bb_alog_sms(conn, sms, "REJECTED - not white-regex-listed SMS");
> -        msg_destroy(sms);
> +             octstr_get_cstr(msg->sms.sender));
> +        bb_alog_sms(conn, msg, "REJECTED - not white-regex-listed SMS");
> +        msg_destroy(msg);
>          return SMSCCONN_FAILED_REJECTED;
>      }
>      
>      if (black_list &&
> -	numhash_find_number(black_list, sms->sms.sender) == 1) {
> +	numhash_find_number(black_list, msg->sms.sender) == 1) {
>  	info(0, "Number <%s> is in black-list, message discarded",
> -	     octstr_get_cstr(sms->sms.sender));
> -	bb_alog_sms(conn, sms, "REJECTED - black-listed SMS");
> -	msg_destroy(sms);
> +	     octstr_get_cstr(msg->sms.sender));
> +	bb_alog_sms(conn, msg, "REJECTED - black-listed SMS");
> +	msg_destroy(msg);
>  	return SMSCCONN_FAILED_REJECTED;
>      }
>  
> -    if (black_list_regex && (gw_regex_matches(black_list_regex, sms->sms.sender) == NO_MATCH)) {
> +    if (black_list_regex && (gw_regex_matches(black_list_regex, msg->sms.sender) == NO_MATCH)) {
>          info(0, "Number <%s> is not in black-list, message discarded",
> -             octstr_get_cstr(sms->sms.sender));
> -        bb_alog_sms(conn, sms, "REJECTED - black-regex-listed SMS");
> -        msg_destroy(sms);
> +             octstr_get_cstr(msg->sms.sender));
> +        bb_alog_sms(conn, msg, "REJECTED - black-regex-listed SMS");
> +        msg_destroy(msg);
>          return SMSCCONN_FAILED_REJECTED;
>      }
>  
> -    if (sms->sms.sms_type != report_mo)
> -	sms->sms.sms_type = mo;
> +    if (msg->sms.sms_type != report_mo)
> +	msg->sms.sms_type = mo;
>  
>      /* write to store (if enabled) */
> -    if (store_save(msg) == -1)
>  	return SMSCCONN_FAILED_TEMPORARILY;

with this change all MOs will be rejected...

>  
> -    copy = msg_duplicate(sms);
> +    copy = msg_duplicate(msg);
>  
>      /*
>       * Try to reroute internally to an smsc-id without leaving
> @@ -404,31 +387,31 @@
>           */
>          if (route_incoming_to_boxc(copy) == -1) {
>              warning(0, "incoming messages queue too long, dropping a message.");
> -            if (sms->sms.sms_type == report_mo)
> -                bb_alog_sms(conn, sms, "DROPPED Received DLR");
> +            if (msg->sms.sms_type == report_mo)
> +                bb_alog_sms(conn, msg, "DROPPED Received DLR");
>              else
> -                bb_alog_sms(conn, sms, "DROPPED Received SMS");
> +                bb_alog_sms(conn, msg, "DROPPED Received SMS");
>  
>              /* put nack into store-file */
> -            store_save_ack(sms, ack_failed);
> +            store_save_ack(msg, ack_failed);
>  
>              msg_destroy(copy);
>  
> -            msg_destroy(sms);
> +            msg_destroy(msg);
>              gwthread_sleep(0.1); /* letting the queue go down */
>              return SMSCCONN_FAILED_QFULL;
>          }
>      }
>  
> -    if (sms->sms.sms_type != report_mo)
> -	bb_alog_sms(conn, sms, "Receive SMS");
> +    if (msg->sms.sms_type != report_mo)
> +	bb_alog_sms(conn, msg, "Receive SMS");
>      else
> -	bb_alog_sms(conn, sms, "DLR SMS");
> +	bb_alog_sms(conn, msg, "DLR SMS");
>  
>      counter_increase(incoming_sms_counter);
>      if (conn != NULL) counter_increase(conn->received);
>  
> -    msg_destroy(sms);
> +    msg_destroy(msg);
>  
>      return 0;
>  }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.