MCPcopy Create free account
hub / github.com/WiringPi/WiringPi / extractStr

Function extractStr

wiringPi/wpiExtensions.c:147–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 */
146
147static char *extractStr (char *progName, char *p, char **str)
148{
149 char *q, *r ;
150 int quoted = false ;
151
152 if (*p != ':')
153 {
154 verbError ("%s: colon expected", progName) ;
155 return NULL ;
156 }
157
158 ++p ;
159
160 if (*p == '[')
161 {
162 quoted = true ;
163 ++p ;
164 }
165
166 if (!isprint (*p)) // Is this needed?
167 {
168 verbError ("%s: character expected", progName) ;
169 return NULL ;
170 }
171
172 q = p ;
173 if (quoted)
174 {
175 while ((*q != 0) && (*q != ']'))
176 ++q ;
177 }
178 else
179 {
180 while ((*q != 0) && (*q != ':'))
181 ++q ;
182 }
183
184 *str = r = calloc (q - p + 2, 1) ; // Zeros it
185
186 while (p != q)
187 *r++ = *p++ ;
188
189 if (quoted) // Skip over the ] to the :
190 ++p ;
191
192 return p ;
193}
194
195
196

Callers 3

doExtensionDs18b20Function · 0.85
doExtensionDrcSFunction · 0.85
doExtensionDrcNetFunction · 0.85

Calls 1

verbErrorFunction · 0.85

Tested by

no test coverage detected