GETNETCONFIG(3)
π GETNETCONFIG(3) π β the group chat guide to the netconfig database
okay bestie, this one lives in the Library Functions Manual and it's basically the whole friend group of functions that let your app go shopping in the system network configuration database. seven functions, one page, let's go ποΈβ¨
πΈ NAME πΈ
getnetconfig, setnetconfig, endnetconfig, getnetconfigent, freenetconfigent, nc_perror, nc_sperror β get network configuration database entry
π SYNOPSIS π
#include <netconfig.h>
struct netconfig *
getnetconfig(void *handlep);
void *
setnetconfig(void);
int
endnetconfig(void *handlep);
struct netconfig *
getnetconfigent(const char *netid);
void
freenetconfigent(struct netconfig *netconfigp);
void
nc_perror(const char *msg);
char *
nc_sperror(void);
β¨ DESCRIPTION β¨
so the whole point of this little library crew is giving your application access to the system network configuration database, which lives at /etc/netconfig. that's the vibe. π
The getnetconfig() function hands you a pointer to the current entry in the netconfig database, all formatted pretty as a struct netconfig. Call it again? You get the next entry. Again? Next one. It's giving "keep swiping" energy π. You can literally walk the entire netconfig file with it, and when you hit the end of the file, getnetconfig() returns NULL. The handlep argument is the handle you got from setnetconfig().
A call to setnetconfig() is basically binding to or rewinding the netconfig database β like scrolling all the way back to the top of the feed π. You must call setnetconfig() before your very first getnetconfig() call, and honestly you can call it whenever else you want too. But bestie, listen: you do not need to call setnetconfig() before calling getnetconfigent(). Different lane, different rules. setnetconfig() returns a unique handle, and that handle is what getnetconfig() needs.
The endnetconfig() function is your "okay we're done here, clean up" moment β call it when processing is complete so resources can be released and reused. The handlep argument is the handle you got from setnetconfig(). But β οΈ programmers should be aware: the last call to endnetconfig() frees all the memory that getnetconfig() allocated for the struct netconfig data structure. All of it. Gone. So don't be out here holding pointers like they're still valid π. Also endnetconfig() may not be called before setnetconfig() β no skipping steps, that's not the vibe.
The getnetconfigent() function returns a pointer to the netconfig structure that corresponds to netid. If netid is invalid β meaning it doesn't name an entry in the netconfig database β you get NULL. that's it, that's the deal π
The freenetconfigent() function frees the netconfig structure pointed to by netconfigp, which should be something you previously got back from getnetconfigent(). recycle your pointers, queen β»οΈ
The nc_perror() function prints a message to standard error explaining why any of the above routines failed. The message gets the string msg and a colon prepended to it, and a newline character gets appended at the end. nice and tidy, no notes π
The nc_sperror() function is basically nc_perror()'s twin, except instead of yeeting the message to standard error, it returns a pointer to a string containing the error message. same energy, different delivery method π
Oh and btw, nc_perror() and nc_sperror() can also be used with the NETPATH access routines defined in getnetpath(3). they're versatile like that, they get along with everyone π«Ά
π₯ RETURN VALUES π₯
setnetconfig()returns a unique handle forgetnetconfig()to use. If something goes wrong, it returnsNULL, and you can hit upnc_perror()ornc_sperror()to find out why it failed. spill the tea, error message π’getnetconfig()returns a pointer to the current entry in the netconfig database, formatted as astruct netconfig. It returnsNULLat the end of the file, or if it just... fails. πendnetconfig()returns0on success and-1on failure β for example, ifsetnetconfig()was never called before it. rude of you, honestly.- On success,
getnetconfigent()returns a pointer to thestruct netconfigstructure corresponding tonetid; otherwise it returnsNULL. periodt. nc_sperror()returns a pointer to a buffer containing the error message string. β οΈ heads up: this buffer is overwritten on each call. And in multithreaded applications, this buffer is implemented as thread-specific data. so like, don't expect it to remember things, it's very much a "living in the moment" buffer π¦
ποΈ FILES ποΈ
/etc/netconfig
π AVAILABILITY π
These functions are part of libtirpc. iconic of them, honestly π
π SEE ALSO π
and that's the whole page bestie, you ate it π this one came from Debian, dated April 22, 2000 β yeah, vintage, but the slay is timeless β¨ππ¦
π¦ 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
- Copyright 1989 AT&T
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms