GETRPCENT(3)
π GETRPCENT π
okay bestie, gather round, because we're diving into the Library Functions Manual and honestly? this one's a little vintage gem π
β¨ NAME β¨
getrpcent, getrpcbyname, getrpcbynumber, endrpcent, setrpcent β get an RPC entry, fr fr π
πΈ SYNOPSIS πΈ
#include <rpc/rpc.h>
struct rpcent *
getrpcent(void);
struct rpcent *
getrpcbyname(char *name);
struct rpcent *
getrpcbynumber(int number);
void
setrpcent(int stayopen);
void
endrpcent(void);
π¦ DESCRIPTION π¦
so here's the tea β β getrpcent(), getrpcbyname(), and getrpcbynumber() all hand you back a pointer to an object. that object has the structure below, and it's literally just the broken-out fields of one line from the rpc program number data base, which lives at /etc/rpc ποΈ
struct rpcent {
char *r_name; /* name of server for this rpc program */
char **r_aliases; /* alias list */
long r_number; /* rpc program number */
};
and the members of that struct? let me break it down for you π
r_nameβ the name of the server for this rpc program. that's it, that's the name π·οΈr_aliasesβ a zero terminated list of alternate names for the rpc program. so like, the government names, plural πr_numberβ the rpc program number for this service. the digits, the ID, the whole vibe π’
getrpcent() reads the next line of the file, and it'll open the file for you if it needs to. no prep required, she's self-sufficient π
β¨
setrpcent() opens and rewinds the file. and here's the key part: if the stayopen flag is non-zero, the net data base will not be closed after each call to getrpcent() β whether you call it directly or sneakily indirectly through one of the other βgetrpcβ calls π keep that file held open, queen.
endrpcent() closes the file. that's the whole job, and she does it flawlessly π«Ά
getrpcbyname() and getrpcbynumber() do a sequential search from the beginning of the file β just walking it down, line by line β until they hit a matching rpc program name or program number, or until they smash into end-of-file. no shortcuts, no index, just vibes and determination π
π FILES π
/etc/rpc
π AVAILABILITY π
these functions are part of libtirpc. that's the home, that's where they live π‘
π SEE ALSO π
go read those too, i'm not asking π
π©Ί DIAGNOSTICS π©Ί
a NULL pointer is returned on EOF or error. so if you get NULL, that's the universe telling you something went sideways or you just ran out of file π
π BUGS π
okay so this is the important one, bestie, listen up:
all information is contained in a static area, so it must be copied if it is to be saved. do not, i repeat, do not just hold onto that pointer and assume it'll still say the same thing later. she will change on you. copy it. periodt. π
π the cute sign-off π
this page is from Debian, and it's been serving looks since December 14, 1987 β an absolute icon, aging like fine wine, still relevant, still slaying ππβ¨
π¦ where this page comes from
- alpine 3.22: libtirpc-doc 1.3.5-r0 Β· BSD-3-Clause
- alpine 3.23: libtirpc-doc 1.3.5-r1 Β· BSD-3-Clause
- alpine 3.24: libtirpc-doc 1.3.5-r1 Β· BSD-3-Clause
- arch rolling: libtirpc 1.3.8-1 Β· SISSL AND BSD-3-Clause
- centos-stream 10: libtirpc-devel 1.3.5-1.el10 Β· SISSL AND BSD-3-Clause
- centos-stream 9: libtirpc-devel 1.3.3-9.el9 Β· SISSL and BSD
- centos-stream 9: libtirpc-devel 1.3.3-9.el9 Β· SISSL and BSD
- debian bookworm: libtirpc-dev 1.3.3+ds-1 Β· BSD-3-Clause
- debian trixie: libtirpc-dev 1.3.6+ds-1 Β· BSD-3-Clause
- fedora 43: libtirpc-devel 1.3.7-0.fc43 Β· SISSL AND BSD-3-Clause
- fedora 43: libtirpc-devel 1.3.7-0.fc43 Β· SISSL AND BSD-3-Clause
- fedora 43: libtirpc-devel 1.3.7-1.rc1.fc43 Β· SISSL AND BSD-3-Clause
- fedora 43: libtirpc-devel 1.3.7-1.rc1.fc43 Β· SISSL AND BSD-3-Clause
- fedora 44: libtirpc-devel 1.3.7-2.fc44 Β· SISSL AND BSD-3-Clause
- fedora 44: libtirpc-devel 1.3.7-2.fc44 Β· SISSL AND BSD-3-Clause
- fedora 44: libtirpc-devel 1.3.8-0.fc44 Β· SISSL AND BSD-3-Clause
- fedora 44: libtirpc-devel 1.3.8-0.fc44 Β· SISSL AND BSD-3-Clause
- nixos 26.05: libtirpc 1.3.7
- nixpkgs unstable: libtirpc 1.3.7
- opensuse-leap 16.0: libtirpc-devel 1.3.6-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libtirpc-devel 1.3.6-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libtirpc-devel 1.3.6-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libtirpc-devel 1.3.6-160000.2.2 Β· BSD-3-Clause
- ubuntu jammy: libtirpc-dev 1.3.2-2build1 Β· BSD-3-Clause
- ubuntu jammy: libtirpc-dev 1.3.2-2ubuntu0.1 Β· BSD-3-Clause
- ubuntu noble: libtirpc-dev 1.3.4+ds-1.1build1 Β· BSD-3-Clause
- ubuntu questing: libtirpc-dev 1.3.6+ds-1
- ubuntu resolute: libtirpc-dev 1.3.7-0.1 Β· BSD-3-Clause
- ubuntu stonking: libtirpc-dev 1.3.7+ds-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms