masqmail

diff src/rewrite.c @ 10:26e34ae9a3e3

changed indention and line wrapping to a more consistent style
author meillo@marmaro.de
date Mon, 27 Oct 2008 16:23:10 +0100
parents 08114f7dcc23
children f671821d8222
line diff
     1.1 --- a/src/rewrite.c	Mon Oct 27 16:21:27 2008 +0100
     1.2 +++ b/src/rewrite.c	Mon Oct 27 16:23:10 2008 +0100
     1.3 @@ -20,81 +20,78 @@
     1.4  #include "masqmail.h"
     1.5  #endif
     1.6  
     1.7 -gboolean set_address_header_domain(header *hdr, gchar *domain)
     1.8 +gboolean
     1.9 +set_address_header_domain(header * hdr, gchar * domain)
    1.10  {
    1.11 -  gchar *p = hdr->value;
    1.12 -  gchar *new_hdr = g_strndup(hdr->header, hdr->value - hdr->header);
    1.13 -  gint tmp;
    1.14 +	gchar *p = hdr->value;
    1.15 +	gchar *new_hdr = g_strndup(hdr->header, hdr->value - hdr->header);
    1.16 +	gint tmp;
    1.17  
    1.18 -  while(*p){
    1.19 -    gchar *loc_beg, *loc_end;
    1.20 -    gchar *dom_beg, *dom_end;
    1.21 -    gchar *addr_end;
    1.22 -    gchar *rewr_string;
    1.23 +	while (*p) {
    1.24 +		gchar *loc_beg, *loc_end;
    1.25 +		gchar *dom_beg, *dom_end;
    1.26 +		gchar *addr_end;
    1.27 +		gchar *rewr_string;
    1.28  
    1.29 -    if(parse_address_rfc822(p,
    1.30 -			    &loc_beg, &loc_end, &dom_beg, &dom_end, &addr_end)){
    1.31 -      gchar *left, *right;
    1.32 +		if (parse_address_rfc822(p, &loc_beg, &loc_end, &dom_beg, &dom_end, &addr_end)) {
    1.33 +			gchar *left, *right;
    1.34  
    1.35 -      if(dom_beg != NULL){
    1.36 -	left = g_strndup(p, dom_beg - p);
    1.37 -	right = g_strndup(dom_end, addr_end - dom_end);
    1.38 +			if (dom_beg != NULL) {
    1.39 +				left = g_strndup(p, dom_beg - p);
    1.40 +				right = g_strndup(dom_end, addr_end - dom_end);
    1.41  
    1.42 -	rewr_string = g_strconcat(left, domain, right, NULL);
    1.43 -      }else{
    1.44 -	left = g_strndup(p, loc_end - p);
    1.45 -	right = g_strndup(loc_end, addr_end - loc_end);
    1.46 +				rewr_string = g_strconcat(left, domain, right, NULL);
    1.47 +			} else {
    1.48 +				left = g_strndup(p, loc_end - p);
    1.49 +				right = g_strndup(loc_end, addr_end - loc_end);
    1.50  
    1.51 -	rewr_string = g_strconcat(left, "@", domain, right, NULL);
    1.52 -      }
    1.53 -      g_free(left);
    1.54 -      g_free(right);
    1.55 +				rewr_string = g_strconcat(left, "@", domain, right, NULL);
    1.56 +			}
    1.57 +			g_free(left);
    1.58 +			g_free(right);
    1.59  
    1.60 -      p = addr_end;
    1.61 -      if(*p == ',') p++;
    1.62 +			p = addr_end;
    1.63 +			if (*p == ',')
    1.64 +				p++;
    1.65  
    1.66 -      new_hdr =
    1.67 -	g_strconcat(new_hdr, rewr_string,
    1.68 -		    *p != 0 ? "," : NULL, NULL);
    1.69 +			new_hdr = g_strconcat(new_hdr, rewr_string, *p != 0 ? "," : NULL, NULL);
    1.70  
    1.71 -    }else
    1.72 -      return FALSE;
    1.73 -  }
    1.74 -  tmp = (hdr->value - hdr->header);
    1.75 -  g_free(hdr->header);
    1.76 -  hdr->header = new_hdr;
    1.77 -  hdr->value = hdr->header + tmp;
    1.78 +		} else
    1.79 +			return FALSE;
    1.80 +	}
    1.81 +	tmp = (hdr->value - hdr->header);
    1.82 +	g_free(hdr->header);
    1.83 +	hdr->header = new_hdr;
    1.84 +	hdr->value = hdr->header + tmp;
    1.85  
    1.86 -  return TRUE;
    1.87 +	return TRUE;
    1.88  }
    1.89  
    1.90 -gboolean map_address_header(header *hdr, GList *table)
    1.91 +gboolean
    1.92 +map_address_header(header * hdr, GList * table)
    1.93  {
    1.94 -  GList *addr_list = addr_list_append_rfc822(NULL, hdr->value, conf.host_name);
    1.95 -  GList *addr_node;
    1.96 -  gchar *new_hdr = g_strndup(hdr->header, hdr->value - hdr->header);
    1.97 -  gboolean did_change = FALSE;
    1.98 +	GList *addr_list = addr_list_append_rfc822(NULL, hdr->value, conf.host_name);
    1.99 +	GList *addr_node;
   1.100 +	gchar *new_hdr = g_strndup(hdr->header, hdr->value - hdr->header);
   1.101 +	gboolean did_change = FALSE;
   1.102  
   1.103 -  foreach(addr_list, addr_node){
   1.104 -    address *addr = (address *)(addr_node->data);
   1.105 -    gchar *rewr_string = (gchar *)table_find_fnmatch(table, addr->local_part);
   1.106 +	foreach(addr_list, addr_node) {
   1.107 +		address *addr = (address *) (addr_node->data);
   1.108 +		gchar *rewr_string = (gchar *) table_find_fnmatch(table, addr->local_part);
   1.109  
   1.110 -    if(rewr_string == NULL)
   1.111 -      rewr_string = addr->address;
   1.112 -    else
   1.113 -      did_change = TRUE;
   1.114 +		if (rewr_string == NULL)
   1.115 +			rewr_string = addr->address;
   1.116 +		else
   1.117 +			did_change = TRUE;
   1.118  
   1.119 -    if(rewr_string)
   1.120 -      new_hdr =
   1.121 -	g_strconcat(new_hdr, rewr_string,
   1.122 -		    g_list_next(addr_node) ? "," : "\n", NULL);
   1.123 -  }
   1.124 -  if(did_change){
   1.125 -    g_free(hdr->header);
   1.126 -    hdr->header = new_hdr;
   1.127 -  }else
   1.128 -    g_free(new_hdr);
   1.129 +		if (rewr_string)
   1.130 +			new_hdr = g_strconcat(new_hdr, rewr_string, g_list_next(addr_node) ? "," : "\n", NULL);
   1.131 +	}
   1.132 +	if (did_change) {
   1.133 +		g_free(hdr->header);
   1.134 +		hdr->header = new_hdr;
   1.135 +	} else
   1.136 +		g_free(new_hdr);
   1.137  
   1.138 -  return did_change;
   1.139 +	return did_change;
   1.140  }
   1.141 -