mbed-os-mbed-os-5.10.4/TEST_APPS/device/socket_app/cmd_socket.cpp
/** Generate RFC 864 example pattern.
 *
 * Pattern is 72 chraracter lines of the ASCII printing characters ending with "\r\n".
 * There are 95 printing characters in the ASCII character set.
 * Example: `nc echo.mbedcloudtesting.com 19 | dd bs=1 count=222`
 *  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg
 * !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh
 * "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
 *
 * NOTE: Pattern starts with space, not !
 *
 * \param offset Start pattern from offset
 * \param len Length of pattern to generate.
 */
Generate RFC 864 example pattern.
Pattern is 72 chraracter lines of the ASCII printing characters ending with "\r\n".
There are 95 printing characters in the ASCII character set.

Pattern starts with space, not !

\param offset Start pattern from offset
\param len Length of pattern to generate.
Generate RFC 864 example pattern . Pattern is 72 chraracter lines of the ASCII printing characters ending with " \ r \ n " . There are 95 printing characters in the ASCII character set . Pattern starts with space not ! \ param offset Start pattern from offset \ param len Length of pattern to generate .
static void generate_RFC_864_pattern(size_t offset, uint8_t *buf,  size_t len, bool is_xinetd)
{
    const int row_size = 74; 
    const int row_count = 95; 
    const int chars_scope = is_xinetd ? 93 : 95; 
    const char first_char = is_xinetd ? '!' : ' '; 
    while (len--) {
        if (offset % row_size == (row_size - 2)) {
            *buf++ = '\r';
        } else if (offset % row_size == (row_size - 1)) {
            *buf++ = '\n';
        } else {
            *buf++ = first_char + (offset % row_size + ((offset / row_size) % row_count)) % chars_scope;
        }
        offset++;
    }
}
static void generate_RFC_864_pattern ( size_t offset , uint8_t * buf , size_t len , bool is_xinetd ) { const int row_size = 74 ; const int row_count = 95 ; const int chars_scope = is_xinetd ? 93 : 95 ; const char first_char = is_xinetd ? ' ' : ' ' ; while ( len -- ) { if ( offset % row_size == ( row_size - 2 ) ) { * buf ++ = ' \r ' ; } else if ( offset % row_size == ( row_size - 1 ) ) { * buf ++ = ' \n ' ; } else { * buf ++ = first_char + ( offset % row_size + ( ( offset / row_size ) % row_count ) ) % chars_scope ; } offset ++ ; } }
Generate RFC 864 example pattern.
Generate RFC 864 example pattern .
// Number of chars in single row // Number of rows in pattern after which pattern start from beginning // Number of chars from ASCII table used in pattern // First char from ASCII table used in pattern