MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parseAdaptParameters

Function parseAdaptParameters

freebsd/contrib/zstd/programs/zstdcli.c:516–530  ·  view source on GitHub ↗

parseAdaptParameters() : * reads adapt parameters from *stringPtr (e.g. "--zstd=min=1,max=19) and store them into adaptMinPtr and adaptMaxPtr. * Both adaptMinPtr and adaptMaxPtr must be already allocated and correctly initialized. * There is no guarantee that any of these values will be updated. * @return 1 means that parsing was successful, * @return 0 in case of malformed parameters *

Source from the content-addressed store, hash-verified

514 * @return 0 in case of malformed parameters
515 */
516static unsigned parseAdaptParameters(const char* stringPtr, int* adaptMinPtr, int* adaptMaxPtr)
517{
518 for ( ; ;) {
519 if (longCommandWArg(&stringPtr, "min=")) { *adaptMinPtr = (int)readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; }
520 if (longCommandWArg(&stringPtr, "max=")) { *adaptMaxPtr = (int)readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; }
521 DISPLAYLEVEL(4, "invalid compression parameter \n");
522 return 0;
523 }
524 if (stringPtr[0] != 0) return 0; /* check the end of string */
525 if (*adaptMinPtr > *adaptMaxPtr) {
526 DISPLAYLEVEL(4, "incoherent adaptation limits \n");
527 return 0;
528 }
529 return 1;
530}
531
532
533/** parseCompressionParameters() :

Callers 1

mainFunction · 0.85

Calls 2

longCommandWArgFunction · 0.85
readU32FromCharFunction · 0.70

Tested by

no test coverage detected