/** *parse_hex_sentence()-Convertaasciihexrepresentationintobytearray. *@in:Inputbufferofascii. *@isize:Lengthofinputbuffer. *@out:Outputbuffer. *@osize:Lengthofoutputbuffer,e.g.maxnumberofbytestoparse. * *Anvalidinputisaseriesofasciihexadecimalnumbers,separatedbyspaces. *Anexamplevalidinputis *"00f2000007660ff" * *Ifanindividual"word"withinthehexsentenceislongerthanMAX_WORD_SIZE, *thenthesentenceisillegal,andparsingwillfail. * *Return:Numberofbytesparsed,ornegativeerrorcodeonfailure.
*/ staticint parse_hex_sentence(constchar *in, int isize, u8 *out, int osize)
{ int n_parsed = 0; int word_start = 0; int word_end; int word_len; /* Temp buffer for holding a "word" of chars that represents one byte */ #define MAX_WORD_SIZE 16 char tmp[MAX_WORD_SIZE + 1];
u8 byte;
while (word_start < isize && n_parsed < osize) { /* Find the start of the next word */ while (word_start < isize && isspace(in[word_start]))
word_start++; /* reached the end of the input before next word? */ if (word_start >= isize) break;
/* Find the end of this word */
word_end = word_start; while (word_end < isize && !isspace(in[word_end]))
word_end++;
/* Copy to a tmp NULL terminated string */
word_len = word_end - word_start; if (word_len > MAX_WORD_SIZE) return -EINVAL;
memcpy(tmp, in + word_start, word_len);
tmp[word_len] = '\0';
ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE); if (ret < 0) return ret; /* Need at least two bytes for message type and one byte of data */ if (ret < 3) return -EINVAL;
if (debug_info->response_size) {
fmt_len = hex_dump_to_buffer(debug_info->raw_data,
debug_info->response_size, 16, 1, debug_info->formatted_data, sizeof(debug_info->formatted_data), true); /* Only return response the first time it is read */
debug_info->response_size = 0;
}
/* Format is unused since it is only required for get method which is NULL */
DEFINE_DEBUGFS_ATTRIBUTE(fops_test_event, NULL, test_event_set, "%llu\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.