PROPERTIES(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– PROPERTIES(3) πŸ’–

Okay so this is the PROPERTIES(3) manual page bestie, and it's literally all about the property list functions from the System Utilities Library β€” you know, libutil, link it with -lutil 🫢. These functions are here to let you create simple property lists from ASCII file data, and honestly? It's giving useful. πŸ’…


✨ LIBRARY ✨

So this whole situation lives in the System Utilities Library β€” that's libutil, and you link against it with -lutil. Periodt. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

Here's the whole vibe in code form, keep it exact bestie:

#include <libutil.h>

properties
properties_read(int fd);

char *
property_find(properties list, const char *name);

void
properties_free(properties list);

πŸŽ€ DESCRIPTION πŸŽ€

First up, the struct β€” this is the whole personality of the thing:

typedef struct _properties {
        struct _properties *next;
        char *name;
        char *value;
} *properties;

Now let me walk you through the functions because they're literally so straightforward:

  • properties_read(int fd) β€” so this one reads name = value pairs from the file descriptor you pass in fd, and it returns the head of a brand new property list. Assuming everything parsed properly, of course. If something goes wrong? You get NULL back. No cap. 😭
  • property_find(properties list, const char *name) β€” this one's the lookup bestie. Give it the property list and a name, and it returns the associated value string if it finds it. If not? NULL. And heads up β€” the value you get back may be up to PROPERTY_MAX_VALUE bytes in length, so don't get caught lacking. πŸ”₯
  • properties_free(properties list) β€” when you're done with the structure that properties_read() returned, this is the one that frees it. Clean up after yourself, queen. πŸ’œ

🌈 FILE FORMAT 🌈

Okay so the tea on how files should be formatted: each property in the file is assumed to have the format of name = value where name is an alphanumeric string β€” and any punctuation not including the = character β€” and value is an arbitrary string of text terminated by a newline character. Simple enough, right? πŸ’–

But wait β€” if you want newlines inside your value? You gotta enclose the entire value in { } (curly-bracket) characters. That's the trick. πŸ¦‹

And any line beginning with a # or ; character is assumed to be a comment and will be ignored. Iconic. ✨


πŸ‘‘ AUTHORS πŸ‘‘

This masterpiece was written by Jordan Hubbard. We stan. 🫢


πŸ’€ BUGS πŸ’€

Okay so the bug section is literally just one word: Simplistic. That's it. That's the whole bug report. I'm not even kidding. πŸ’€


That's the whole page bestie! This came from the Debian version, dated October 7, 1998 β€” like, a literal relic from the 90s and we're still using it. Vintage icon behavior. πŸŽ€ Stay slaying with those property lists! πŸ’…

πŸ“¦ where this page comes from