MCPcopy Create free account
hub / github.com/Sapd/HeadsetControl / get_byte_data_from_parameter

Function get_byte_data_from_parameter

src/utility.c:85–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int get_byte_data_from_parameter(char* input, unsigned char* dest, size_t len)
86{
87 const char* delim = " ,{}\n\r";
88
89 // Make a copy of the input string to avoid modifying the original
90 char* input_copy = strdup(input);
91 if (input_copy == NULL) {
92 // Memory allocation failed
93 return -1;
94 }
95
96 // For each token in the string, parse and store in buf[].
97 char* token = strtok(input, delim);
98 int i = 0;
99 while (token) {
100 char* endptr;
101 long int val = strtol(token, &endptr, 0);
102
103 if (i >= len)
104 return -1;
105
106 dest[i++] = val;
107 token = strtok(NULL, delim);
108 }
109
110 return i;
111}
112
113int get_float_data_from_parameter(char* input, float* dest, size_t len)
114{

Callers 1

dev_mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected