PMPARSEINTERVAL(3)
β¨ PMPARSEINTERVAL β¨
okay bestie, welcome to pmParseInterval π this one lives in the PMPARSEINTERVAL(3) corner of the Library Functions Manual, and honestly? she's giving "glow-up from string to struct" and we're obsessed.
πΈ NAME πΈ
pmParseInterval β literally converts an interval string into a binary time structure. that's it, that's the job, no cap π
π C SYNOPSIS π
#include <pcp/pmapi.h>
int pmParseInterval(const char *string, struct timespec *rslt,
char **errmsg);
cc ... -lpcp
yeah so you include <pcp/pmapi.h>, you link with -lpcp, and you get a function with three args and a whole lot of main character energy π₯
π¦ DESCRIPTION π¦
so here's the vibe: pmParseInterval takes the argument string β which is describing an interval of time β parses it, and fills in the tv_sec and tv_nsec components of the rslt structure so they represent that interval. nanosecond precision, bestie, we do NOT round here β¨
where does this string usually come from? most commonly it's the argument that follows a -t command line option to a PCP application. and the syntax of that string? it's fully described in PCPIntro(1) β go read her, she ate π
π DIAGNOSTICS π
okay so the results are very much a vibe check:
- if the parsing is successful,
pmParseIntervalreturns0, anderrmsgis undefined. (yes, undefined. don't look at it. it's not for you π) - if the given
stringdoes not conform to the required syntax,pmParseIntervalreturns-1and hands you a dynamically allocated error message string inerrmsg.
that error message is terminated with a newline, and it includes the text of the input string along with an indicator of the position at which the error was detected, like this:
4minutes 30mumble
^ -- unexpected value
β οΈ important bestie: in the case of an error, the caller is responsible for callingfree(3)to release the space allocated forerrmsg. yes, YOU. it's your job. don't leave her hanging π
π COMPATIBILITY π
history lesson, come sit with me π«Ά
prior to PCP 7.0, the rslt argument was a struct timeval. so if you're dealing with old code, here's the tea: to support PMAPI transition, the old interface and semantics can be used if applications are recompiled with -DPMAPI_VERSION=2.
and for a time in PCP 6.x, there was a routine with the same semantics as the current pmParseInterval called pmParseHighResInterval. however β and I need you to hear this β this is now deprecated, and compile-time support for pmParseHighResInterval will be removed in a future release. so like, don't get attached π
π SEE ALSO π
PCPIntro(1), free(3), PMAPI(3) and pmParseTimeWindow(3) β go give them a follow, they're all part of the friend group β¨
that's the whole page, bestie π she's brought to you by Performance Co-Pilot, from PCP, and she's iconic, periodt. mwah π ππ¦
π¦ where this page comes from
- arch rolling: pcp 7.2.2-2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later AND CC-BY-3.0
- centos-stream 10: pcp-doc 7.1.5-6.el10 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.0.1-1.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 43: pcp-doc 7.2.1-1.fc43
- fedora 43: pcp-doc 7.2.2-1.fc43
- fedora 43: pcp-doc 7.2.2-2.fc43 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.1.0-6.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- fedora 44: pcp-doc 7.2.1-1.fc44
- fedora 44: pcp-doc 7.2.2-1.fc44
- fedora 44: pcp-doc 7.2.2-2.fc44 Β· GPL-2.0-or-later AND CC-BY-3.0
- ubuntu resolute: libpcp4-dev 7.1.1-1
- ubuntu stonking: libpcp4-dev 7.2.1-2build1
- 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