PMPARSEINTERVAL(3)
π PMPARSEINTERVAL(3) β Library Functions Manual π
okay bestie, welcome to the interval-parsing corner of the PCP universe β¨ this is pmParseInterval and its glow-up cousin pmParseHighResInterval, and they're literally here to turn your cute little human-readable time string into an actual binary time structure. no cap. ππ
πΈ NAME πΈ
pmParseInterval, pmParseHighResInterval β convert interval string to binary time structure π¦
β¨ C SYNOPSIS β¨
so first, you gotta pull in the header, obviously:
#include <pcp/pmapi.h>
and then the two icons themselves:
int pmParseInterval(const char *string, struct timeval *urslt,
char **errmsg);
int pmParseHighResInterval(const char *string, struct timespec *nrslt,
char **errmsg);
and when you compile, don't forget your girl:
cc ... -lpcp
π DESCRIPTION π
okay so pmParseInterval β she takes the argument string, which is specifying an interval of time, parses it, and fills in the tv_sec and tv_usec components of the urslt structure so that it represents that interval. that's microsecond precision, bestie. so precise. π
and then pmParseHighResInterval is the same vibe but leveled up β¨ she parses the argument string and fills in the tv_sec and tv_nsec components of the nrslt structure to represent that interval. nanosecond precision. she ate and left no crumbs fr fr π
now, where does this string usually come from? most commonly it's the argument following a -t command line option to a PCP application π« and the syntax β the whole grammar of it β is fully described in PCPIntro(1). so if you're like "wait what can I even put in here", go read that one, iykyk π
π DIAGNOSTICS π
so here's the vibe check on what these functions hand back:
- if the parsing is successful,
pmParseIntervalreturns0, anderrmsgis undefined. iconic, no notes π - if the given string does not conform to the required syntax,
pmParseIntervalreturns-1and hands you a dynamically allocated error message string inerrmsg. π¬
and that error message? she's terminated with a newline, and she includes the text of the input string along with an indicator of the position at which the error was detected. like, she points at the problem. so helpful. for example:
4minutes 30mumble
^ -- unexpected value
see how she's pointing right at the 30mumble? that caret is doing the lord's work π
β οΈ important bestie, listen up: in the case of an error, the caller is responsible for callingfree(3)to release the space allocated forerrmsg. don't leave her hanging, don't leak that memory. free her. periodt. π
π«Ά SEE ALSO π«Ά
PCPIntro(1), free(3), PMAPI(3) and pmParseTimeWindow(3) π
that's the whole page, and you absolutely understood all of it, i'm so proud π₯Ή
this masterpiece comes to you from Performance Co-Pilot β PCP β and it lives at PMPARSEINTERVAL(3). mwah, go parse something π
π
π¦ where this page comes from
- centos-stream 9: pcp-doc 6.3.7-14.el9 Β· GPL-2.0-or-later AND CC-BY-3.0
- debian trixie: libpcp3-dev 6.3.8-1
- ubuntu questing: libpcp3-dev 6.3.8-1
- Copyright (c) 2022 Red Hat
- Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms