subsys/debug/gdb_server.c
/**
 * @brief write a XML string into output buffer
 *
 * It takes care of offset, length and also deal with overflow (if the XML
 * string is bigger than the output buffer).
 */
@brief write a XML string into output buffer
It takes care of offset, length and also deal with overflow (if the XML
string is bigger than the output buffer).
@brief write a XML string into output buffer It takes care of offset length and also deal with overflow ( if the XML string is bigger than the output buffer ) .
static void write_xml_string(char *buf, const char *xml_str, int off, int len)
{
	size_t max_len = strlen(xml_str);
	if (off == max_len) {
		strncat((char *)buf, "l", len - 1);
	} else if (off > max_len) {
		fill_output_buffer("E00");
	} else {
		if ((off + max_len) <= len) {
			buf[0] = 'l';
			int size_to_copy = len <= (GDB_BUF_SIZE - 2) ? len :
					   GDB_BUF_SIZE - 2;
			strncpy(&buf[1], xml_str + off, size_to_copy);
		} else {
			buf[0] = 'm';
			strncpy(&buf[1], xml_str + off, GDB_BUF_SIZE - 2);
			buf[len + 1] = '\0';
		}
	}
}
static void write_xml_string ( char * buf , const char * xml_str , int off , int len ) { size_t max_len = strlen ( xml_str ) ; if ( off == max_len ) { strncat ( ( char * ) buf , " " , len - 1 ) ; } else if ( off > max_len ) { fill_output_buffer ( " " ) ; } else { if ( ( off + max_len ) <= len ) { buf [ 0 ] = ' ' ; int size_to_copy = len <= ( GDB_BUF_SIZE - 2 ) ? len : GDB_BUF_SIZE - 2 ; strncpy ( & buf [ 1 ] , xml_str + off , size_to_copy ) ; } else { buf [ 0 ] = ' ' ; strncpy ( & buf [ 1 ] , xml_str + off , GDB_BUF_SIZE - 2 ) ; buf [ len + 1 ] = ' \0 ' ; } } }
@brief write a XML string into output buffer
 It takes care of offset, length and also deal with overflow (if the XML
 string is bigger than the output buffer).
@brief write a XML string into output buffer It takes care of offset length and also deal with overflow ( if the XML string is bigger than the output buffer ) .
/* we can read the full data */