rem: if (hdr.type==HDR_OTHER || ha->title.s==0) {
add: if (hdr.type==HDR_OTHER_T || ha->title.s==0) {
context: int parse_tw_append( modparam_t type, void* val){	struct hdr_field hdr;	struct hdr_avp *last;	struct hdr_avp *ha;	struct tw_append *app;	int_str avp_name;	char *s;	char bar;	str foo;	int n;		if (val==0 || ((char*)val)[0]==0)		return 0;	s = (char*)val;	/* start parsing - first the name */	while( *s && isspace((int)*s) )  s++;	if ( !*s || *s==':')		goto parse_error;	foo.s = s;	while ( *s && *s!=':' && !isspace((int)*s) ) s++;	if ( !*s || foo.s==s )		goto parse_error;	foo.len = s - foo.s;	/* parse separator */	while( *s && isspace((int)*s) )  s++;	if ( !*s || *s!=':')		goto parse_error;	s++;	while( *s && isspace((int)*s) )  s++;	if ( !*s )		goto parse_error;	/* check for name duplication */	for(app=tw_appends;app;app=app->next)		if (app->name.len==foo.len && !strncasecmp(app->name.s,foo.s,foo.len)){			LOG(L_ERR,"ERROR:tm:parse_tw_append: duplicated tw_append name "				"<%.*s>\n",foo.len,foo.s);			goto error;		}	/* new tw_append structure */	app = (struct tw_append*)pkg_malloc( sizeof(struct tw_append) );	if (app==0) {		LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");		goto error;	}	app->name.s = (char*)pkg_malloc( foo.len+1 );	if (app->name.s==0) {		LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");		goto error;	}	memcpy( app->name.s, foo.s, foo.len);	app->name.len = foo.len;	app->name.s[app->name.len] = 0;	last = app->elems = 0;	app->next = tw_appends;	tw_appends = app;	/* parse the elements */	while (*s) {		/* parse element title or element type */		foo.s = s;		while( *s && *s!='[' && *s!='=' && *s!=';' && !isspace((int)*s) ) s++;		if ( !*s || foo.s==s)			goto parse_error;		foo.len = s - foo.s;		/* new hdr_avp structure */		ha = (struct hdr_avp*)pkg_malloc( sizeof(struct hdr_avp) );		if (ha==0) {			LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");			goto error;		}		memset( ha, 0, sizeof(struct hdr_avp));		if (*s!='[') {			/* foo must by title or some error -> parse separator */			while( *s && isspace((int)*s) )  s++;			if ( !*s || *s!='=')				goto parse_error;			s++;			while( *s && isspace((int)*s) )  s++;			if ( !*s )				goto parse_error;			/* set the title */			ha->title.s = (char*)pkg_malloc( foo.len+1 );			if (ha->title.s==0) {				LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg memory\n");				goto error;			}			memcpy( ha->title.s, foo.s, foo.len);			ha->title.len = foo.len;			ha->title.s[ha->title.len] = 0;			/* parse the type now */			foo.s = s;			while( *s && *s!='[' && *s!=']' && *s!=';' && !isspace((int)*s) )				s++;			if ( *s!='[' || foo.s==s)				goto parse_error;			foo.len = s - foo.s;		}		/* foo containes the elemet type */		if ( foo.len==ELEM_TYPE_AVP_LEN &&		!strncasecmp( foo.s, ELEM_TYPE_AVP, foo.len) ) {			ha->type = ELEM_IS_AVP;		} else if ( foo.len==ELEM_TYPE_HDR_LEN &&		!strncasecmp( foo.s, ELEM_TYPE_HDR, foo.len) ) {			ha->type = ELEM_IS_HDR;		} else if ( foo.len==ELEM_TYPE_MSG_LEN &&		!strncasecmp( foo.s, ELEM_TYPE_MSG, foo.len) ) {			ha->type = ELEM_IS_MSG;		} else {			LOG(L_ERR,"ERROR:tm:parse_tw_append: unknown type <%.*s>\n",				foo.len, foo.s);			goto error;		}		/* parse the element name */		s++;		foo.s = s;		while( *s && *s!=']' && *s!=';' && !isspace((int)*s) ) s++;		if ( *s!=']' || foo.s==s )			goto parse_error;		foo.len = s - foo.s;		s++;		/* process and optimize the element name */		if (ha->type==ELEM_IS_AVP) {			/* element is AVP */			if ( parse_avp_spec( &foo, &n, &avp_name)!=0 ) {				LOG(L_ERR,"ERROR:tm:parse_tw_append: bad alias spec "					"<%.*s>\n",foo.len, foo.s);				goto error;			}			if (n&AVP_NAME_STR) {				/* string name */				ha->sval.s = (char*)pkg_malloc(avp_name.s->len+1);				if (ha->sval.s==0) {					LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg mem\n");					goto error;				}				memcpy( ha->sval.s, avp_name.s->s, avp_name.s->len);				ha->sval.len = avp_name.s->len;				ha->sval.s[ha->sval.len] = 0;				if (ha->title.s==0)					ha->title = ha->sval;			} else {				/* ID name - if title is missing, convert the ID to				 * string and us it a title */				ha->ival = avp_name.n;				if (ha->title.s==0) {					foo.s=int2str((unsigned long)ha->ival, &foo.len);					ha->title.s = (char*)pkg_malloc( n+1 );					if (ha->title.s==0) {						LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg "							"memory\n");						goto error;					}					memcpy( ha->title.s, foo.s, foo.len);					ha->title.len = foo.len;					ha->title.s[ha->title.len] = 0;				}			}		} else if (ha->type==ELEM_IS_HDR) {			/* element is HDR -  try to get it's coded type if defined */			bar = foo.s[foo.len];			foo.s[foo.len] = ':';			/* parse header name */			if (parse_hname2( foo.s, foo.s+foo.len+1, &hdr)==0) {				LOG(L_ERR,"BUG:tm_parse_tw_append: parse header failed\n");				goto error;			}			foo.s[foo.len] = bar;			ha->ival = hdr.type;			if (hdr.type==HDR_OTHER || ha->title.s==0) {				/* duplicate hdr name */				ha->sval.s = (char*)pkg_malloc(foo.len+1);				if (ha->sval.s==0) {					LOG(L_ERR,"ERROR:tm:parse_tw_append: no more pkg mem\n");					goto error;				}				memcpy( ha->sval.s, foo.s, foo.len);				ha->sval.len = foo.len;				ha->sval.s[ha->sval.len] = 0;				if (ha->title.s==0)					ha->title = ha->sval;			}		} else {			/* element is MSG */			if ( !(foo.len==ELEM_VAL_BODY_LEN &&			!strncasecmp(ELEM_VAL_BODY,foo.s,foo.len)) ) {				LOG(L_ERR,"ERROR:tm:parse_tw_append: unsupported value <%.*s>"					" for msg type\n",foo.len,foo.s);				goto error;			}			app->add_body = 1;			pkg_free( ha );			ha = 0;		}		/* parse the element separator, if present */		while( *s && isspace((int)*s) )  s++;		if ( *s && *s!=';')			goto parse_error;		if (*s==';') {			s++;			while( *s && isspace((int)*s) )  s++;			if (!*s)				goto parse_error;		}		/* link the element to tw_append structure */		if (ha) {			if (last==0) {				last = app->elems = ha;			} else {				last->next = ha;				last = ha;			}		}	} /* end while */	print_tw_append( app );	/* free the old string */	pkg_free(val);	return 0;parse_error:	LOG(L_ERR,"ERROR:tm:parse_tw_append: parse error in <%s> around "		"position %ld\n", (char*)val, (long)(s-(char*)val));error:	return -1;}