/**@ingroup tsk_string_group
*/
void tsk_strcat_2(char** destination, const char* format, ...)
{
	char* temp = tsk_null;
	int len;
	va_list ap;
	
	/* initialize variable arguments */
	va_start(ap, format);
	/* compute */
	if((len = tsk_sprintf_2(&temp, format, &ap))){
		tsk_strncat(destination, temp, len);
	}
	/* reset variable arguments */
	va_end(ap);
	TSK_FREE(temp);
}
Exemple #2
0
/** Deserializes a QName.
*/
int tnet_dns_rr_qname_deserialize(const void* data, char** name, tsk_size_t *offset)
{
	/* RFC 1035 - 4.1.4. Message compression

		The pointer takes the form of a two octet sequence:
		+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
		| 1  1|                OFFSET                   |
		+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
	*/
	uint8_t* dataPtr = (((uint8_t*)data) + *offset);
	unsigned usingPtr = 0; /* Do not change. */

	while(*dataPtr){
		usingPtr = ((*dataPtr & 0xC0) == 0xC0);

		if(usingPtr){
			tsk_size_t ptr_offset = (*dataPtr & 0x3F);
			ptr_offset = ptr_offset << 8 | *(dataPtr+1);
			
			*offset += 2;
			return tnet_dns_rr_qname_deserialize(data, name, &ptr_offset);
		}
		else{
			uint8_t length;

			if(*name){
				tsk_strcat(name, ".");
			}	

			length = *dataPtr;
			*offset+=1, dataPtr++;

			tsk_strncat(name, (const char*)dataPtr, length);
			*offset += length, dataPtr += length;
		}
	}

	*offset+=1;

	return 0;
}
/**@ingroup tsk_string_group
* Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, 
* and a new null-character is appended at the end of the new string formed by the concatenation of both in destination. If the destination is NULL then new 
* memory will allocated and filled with source value.
* @param destination Pointer de the destination array containing the new string.
* @param source C string to be appended. This should not overlap destination. If NULL then nothing is done.
*/
void tsk_strcat(char** destination, const char* source)
{
	tsk_strncat(destination, source, tsk_strlen(source));
}