rem: */
context: encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str * result){	struct uri_format format;	char *pos;	int foo,res;		(*result).s = NULL;	(*result).len = 0;	if (uri.len <= 1)		return -1;	/* no contact or an invalid one */	fprintf (stdout, "Primit cerere de encodare a [%.*s] cu %s-%s\n", uri.len,		 uri.s, encoding_prefix, public_ip);	fflush (stdout);	foo = encode2format (uri, &format);	if (foo < 0)		return foo - 20;	fprintf(stdout,"user=%.*s ip=%.*s port=%.*s protocol=%.*s\n",format.username.len,format.username.s,format.ip.len,format.ip.s,	      format.port.len,format.port.s,format.protocol.len,format.protocol.s);   	/* a complete uri would be sip:username@ip:port;transport=protocol goes to	 * sip:enc_pref*username*ip*port*protocol@public_ip	 */	foo = 1;		/*strlen(separator); */	(*result).len = format.first + uri.len - format.second +	//ar trebui sa sterg 1		strlen (encoding_prefix) + foo +		format.username.len + foo +		format.password.len + foo +		format.ip.len + foo + format.port.len + foo +		format.protocol.len + 1 + strlen (public_ip);	/* adding one comes from * */	(*result).s = pkg_malloc ((*result).len);	pos = (*result).s;	if (pos == NULL)	{		fprintf (stdout, "Unable to alloc result [%d] end=%d\n",			 (*result).len, format.second);		goto error2;	}	//memcpy (pos, "sip:", 4);pos = pos + 4;	fprintf (stdout, "Adding [%d] ->%.*s\n", format.first, format.first,uri.s);	fflush (stdout);	/* 			res = snprintf(pos,(*result).len,"%.*s%s%c%.*s%c%.*s%c%.*s%c%.*s@%s",format.first,uri.s,encoding_prefix,separator,		format.username.len,format.username.s,separator,format.password.len,format.password.s,		separator,format.port.len,format.port.s,separator,format.protocol.len,format.protocol.s,public_ip);		if ((res < 0 )||(res>(*result).len)) goto error2;		fprintf(stdout,"res= %d\npos=%s\n",res,pos);		pos = pos + res;		memcpy (pos, uri.s + format.second, uri.len - format.second);		//we have on pos[res] a NULL octet		//it will be NULL terminated		//I can do hacks like writing fewer octets and overwriting the last one		*/	memcpy (pos, uri.s, format.first);	// copy all till sip: inclusive 	pos = pos + format.first;		memcpy (pos, encoding_prefix, strlen (encoding_prefix));	pos = pos + strlen (encoding_prefix);	// might be optimezed by gcc.Will see 	memcpy (pos, &separator, foo);	pos = pos + foo;	if (format.username.len > 0)	{		memcpy (pos, format.username.s, format.username.len);		pos = pos + format.username.len;	}	memcpy (pos, &separator, foo);	pos = pos + foo;	if (format.password.len > 0)	{		memcpy (pos, format.password.s, format.password.len);		pos = pos + format.password.len;	}	memcpy (pos, &separator, foo);	pos = pos + foo;	if (format.ip.len > 0)	{		memcpy (pos, format.ip.s, format.ip.len);		pos = pos + format.ip.len;	}	memcpy (pos, &separator, foo);	pos = pos + foo;	if (format.port.len > 0)	{		memcpy (pos, format.port.s, format.port.len);		pos = pos + format.port.len;	}	memcpy (pos, &separator, foo);	pos = pos + foo;	if (format.protocol.len > 0)	{		memcpy (pos, format.protocol.s, format.protocol.len);		pos = pos + format.protocol.len;	}	memcpy (pos, "@", 1);	pos = pos + 1;		memcpy (pos, public_ip, strlen (public_ip));	pos = pos + strlen (public_ip);	// might be optimezed by gcc.Will see 	memcpy (pos, uri.s + format.second, uri.len - format.second);			fprintf (stdout, "Adding2 [%d] ->%.*s\n", uri.len - format.second,uri.len - format.second, uri.s + format.second);		free_uri_format (format);	fprintf (stdout, "NEW NEW uri is->[%.*s]\n", (*result).len, (*result).s);	return 0;error2:	free_uri_format (format);	return -10;}