MCPcopy Create free account
hub / github.com/RsyncProject/rsync / Parameter

Function Parameter

params.c:266–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264 } /* Section */
265
266static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
267 /* ------------------------------------------------------------------------ **
268 * Scan a parameter name and value, and pass these two fields to pfunc().
269 *
270 * Input: InFile - The input source.
271 * pfunc - A pointer to the function that will be called to
272 * process the parameter, once it has been scanned.
273 * c - The first character of the parameter name, which
274 * would have been read by Parse(). Unlike a comment
275 * line or a section header, there is no lead-in
276 * character that can be discarded.
277 *
278 * Output: True if the parameter name and value were scanned and processed
279 * successfully, else False.
280 *
281 * Notes: This function is in two parts. The first loop scans the
282 * parameter name. Internal whitespace is compressed, and an
283 * equal sign (=) terminates the token. Leading and trailing
284 * whitespace is discarded. The second loop scans the parameter
285 * value. When both have been successfully identified, they are
286 * passed to pfunc() for processing.
287 *
288 * ------------------------------------------------------------------------ **
289 */
290 {
291 int i = 0; /* Position within bufr. */
292 int end = 0; /* bufr[end] is current end-of-string. */
293 int vstart = 0; /* Starting position of the parameter value. */
294 char *func = "params.c:Parameter() -";
295
296 /* Read the parameter name. */
297 while( 0 == vstart ) /* Loop until we've found the start of the value. */
298 {
299
300 if( i > (bSize - 2) ) /* Ensure there's space for next char. */
301 {
302 bSize += BUFR_INC;
303 bufr = realloc_array( bufr, char, bSize );
304 }
305
306 switch( c )
307 {
308 case '=': /* Equal sign marks end of param name. */
309 if( 0 == end ) /* Don't allow an empty name. */
310 {
311 rprintf(FLOG, "%s Invalid parameter name in config file.\n", func );
312 return( False );
313 }
314 bufr[end++] = '\0'; /* Mark end of string & advance. */
315 i = vstart = end; /* New string starts here. */
316 c = EatWhitespace(InFile);
317 break;
318
319 case '\n': /* Find continuation char, else error. */
320 i = Continuation( bufr, i );
321 if( i < 0 )
322 {
323 bufr[end] = '\0';

Callers 1

ParseFunction · 0.85

Calls 4

EatWhitespaceFunction · 0.85
ContinuationFunction · 0.85
isSpaceFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected