'\" t '\"macro stdmacro .\" .\" Copyright (c) 2014,2018 Red Hat. .\" .\" This program is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License as published by the .\" Free Software Foundation; either version 2 of the License, or (at your .\" option) any later version. .\" .\" This program is distributed in the hope that it will be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY .\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License .\" for more details. .\" .\" .TH PMPARSEUNITSSTR 3 "PCP" "Performance Co-Pilot" .SH NAME \f3pmParseUnitsStr\f1 \- parse units specification .SH "C SYNOPSIS" .ft 3 #include .sp .ad l .hy 0 .in +8n .ti -8n int pmParseUnitsStr(const char *\fIstring\fP, struct\ pmUnits\ *\fIout\fP, double\ *\fIoutMult\fP, char\ **\fIerrMsg\fP); .sp .in .hy .ad cc ... \-lpcp .ft 1 .SH DESCRIPTION .B pmParseUnitsStr is designed to encapsulate the interpretation of a units (dimension and scale) specification in command line switches for use by the PCP client tools. .P This function expects to be called with the unit/scale specification as .IR string . This specification takes the general form produced by .BR pmUnitsStr (3). Briefly, the format allows \fB/\fP-separated divisor and dividend, each listing space-separated dimensions/scales along the space, time, and count axes. There are also a few extra possibilities: .PP First, multiple equivalent sets of keywords are accepted for the time and space dimensions, insensitive to case. For example, "microseconds", "microsecond", "microsec", "us" are considered synonymous, as are "kilobytes", "KB", "KiB", "kiloByte", and so on. .PP Second, units may be offered in any order, e.g., \fBms kb count x 10^3\fP or \fBcount x 10^3 kb ms\fP. They may not be repeated within the denominator or within the numerator. Each scale/unit keyword may be immediately followed by positive or negative exponents, e.g., \fB^-4\fP. .PP Third, numerical scaling factors may be supplied. These are factored together with implicit scale conversions into the final .I outMult result. .PP The .I out and .I outMult values must both be allocated before calling .BR pmParseUnitsStr (3). If the conversion is successful, .B pmParseUnitsStr returns 0, and fills in .BR out " and " outMult with the unit/scales defined by the input parameter. If the argument strings could not be parsed, it returns a negative status code. .SH EXAMPLES .TS box,center; c | c | c l | l | l. string out outMult _ 2 count {0,1,0,0,0,0} 0.5 count / 7.5 nanosecond {0,1,-1,0,0,0} 7.5 10 kilobytes / 2.5e2 count x 10^3 {1,-1,0,1,3,0} 25 millisecond / second^2 {0,0,-1,0,0,3} 1000 mib/s {1,0,-1,2,0,3} 1 .TE .SH BUGS For backward compatibility, this interface interprets several traditional computer science interpretations of space units incorrectly by the International System of Units (SI) standard. .PP The accepted unit string \- in either singular or plural form \- and the .B pmParseUnitsStr interpretation for each are: .BR megabyte (\fBmebibyte\fP), .BR gigabyte (\fBgibibyte\fP), .BR terabyte (\fBtebibyte\fP), .BR petabyte (\fBpebibyte\fP), .BR exabyte (\fBexbibyte\fP), .BR zettabyte (\fBzebibyte\fP) and .BR yottabyte (\fByobibyte\fP). .SH RETURN VALUE A zero status indicates success. A negative status indicates an error, in which case the .I errMsg pointer will contain a textual error message, which the caller should later .BR free (3). .SH SEE ALSO .BR PMAPI (3), .BR pmUnitsStr (3), .BR pmConvScale (3), and .BR pmLookupDesc (3).