MCPcopy Create free account
hub / github.com/esnet/iperf / unit_atof_rate

Function unit_atof_rate

src/units.c:136–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 * ------------------------------------------------------------------- */
135
136 double unit_atof_rate(const char *s)
137 {
138 double n;
139 char suffix = '\0';
140
141 assert(s != NULL);
142
143 /* scan the number and any suffices */
144 if (sscanf(s, "%lf%c", &n, &suffix) < 1) {
145 i_errno = IEUNITVAL;
146 errarg = s;
147 return 0;
148 }
149
150 /* convert according to [Tt Gg Mm Kk] */
151 switch (suffix)
152 {
153 case 't': case 'T':
154 n *= TERA_RATE_UNIT;
155 break;
156 case 'g': case 'G':
157 n *= GIGA_RATE_UNIT;
158 break;
159 case 'm': case 'M':
160 n *= MEGA_RATE_UNIT;
161 break;
162 case 'k': case 'K':
163 n *= KILO_RATE_UNIT;
164 break;
165 case '\0':
166 break;
167 default:
168 i_errno = IEUNITVAL;
169 errarg = s;
170 break;
171 }
172 return n;
173 } /* end unit_atof_rate */
174
175
176

Callers 1

iperf_parse_argumentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…