GETNETCONFIG(3)
π» GETNETCONFIG(3) β the netconfig girlies' guide π
okay so this is a Library Functions Manual page, bestie, and it's literally all about getting your network configuration database entries. no cap, it's more useful than it sounds π«Ά
β¨ NAME β¨
getnetconfig, setnetconfig, endnetconfig, getnetconfigent, freenetconfigent, nc_perror, nc_sperror β get network configuration database entry π
π LIBRARY π
Standard C Library (libc, -lc) β she's iconic, she's everywhere, she's linked by default π
πΈ 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 π¦
okay so these library routines are your backstage pass to the system network configuration database, /etc/netconfig. main character access only, iykyk π
getnetconfig()β hands you a pointer to the current entry in the netconfig database, formatted as astruct netconfig. call it again and again and it keeps returning successive entries, like it's scrolling through a feed. it can search the entire netconfig file for you, no skips. when it hits the end of the file it returnsNULL(sad but expected π). thehandlepargument is the handle you got fromsetnetconfig().setnetconfig()β calling this basically "binds" to, or "rewinds", the netconfig database β¨. you must call it before your firstgetnetconfig(), and honestly you can call it at any other time too, no judgement. it does not need to be called beforegetnetconfigent()though β that one's independent, periodt. it returns a unique handle forgetnetconfig()to use.endnetconfig()β call this when you're done processing so resources get released for reuse, very responsible of you π«Ά. thehandlepargument is the handle fromsetnetconfig(). but bestie, heads up π: the last call toendnetconfig()frees all memory allocated bygetnetconfig()for thestruct netconfigdata structure. also, you may not callendnetconfig()beforesetnetconfig()β that's not it.getnetconfigent()β returns a pointer to the netconfig structure corresponding to netid. if netid is invalid (aka it doesn't name an entry in the netconfig database), you getNULL. it's giving "no thoughts head empty" πfreenetconfigent()β frees the netconfig structure pointed to by netconfigp, which you previously got fromgetnetconfigent(). clean up after yourself, queen πnc_perror()β prints a message to the standard error saying why any of the above routines failed. the message gets the string msg and a colon prepended to it, and a newline character is appended at the end. little formatting moment πnc_sperror()β same energy asnc_perror()but instead of sending the message to standard error, it returns a pointer to a string containing the error message. quieter, lowkey, still slays π
also, side note: nc_perror() and nc_sperror() work with the NETPATH access routines defined in getnetpath(3) too. versatile icons π₯
β 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 print the reason for the failure.getnetconfig()β returns a pointer to the current entry in the netconfig database, formatted as astruct netconfig. returnsNULLat the end of the file, or upon failure. it's giving mysterious πendnetconfig()β returns0on success and-1on failure (like, for example, ifsetnetconfig()wasn't called previously β we been knew π).getnetconfigent()β on success, returns a pointer to thestruct netconfigstructure corresponding to netid; otherwise it returnsNULL.nc_sperror()β returns a pointer to a buffer containing the error message string. this buffer gets overwritten on each call, so don't get attached π. in multithreaded applications, this buffer is implemented as thread-specific data β¨ (she's considerate like that).
π FILES π
/etc/netconfigβ the whole vibe lives here
π SEE ALSO π
k that's the whole page, bestie β go forth and configure your networks πβ¨π
this cutie came from the Debian crowd, dated April 22, 2000 β vintage but still serving π¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright 1989 AT&T
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms