NUTSCAN_ADD_OPTION_T(3)

πŸ’– NUTSCAN_ADD_OPTION_T πŸ’–

okay bestie, pull up a chair, we're reading the NUT Manual page for nutscan_add_option_to_device and nutscan_add_commented_option_to_device and honestly? it's giving useful. πŸŽ€


✨ NAME ✨

nutscan_add_option_to_device, nutscan_add_commented_option_to_device β€” add option data to the specified device, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <nut-scan.h>

/* Add enabled option data to the specified device. */
void nutscan_add_option_to_device(
        nutscan_device_t * device,
        char * option_name,
        char * value);

/* Since libnutscan version 2.5.0:
 * Add option data to the specified device with an optional comment tag
 * for options suggested, but not currently enabled for actual use. */
void nutscan_add_commented_option_to_device(
        nutscan_device_t * device,
        char * option_name,
        char * value,
        char * comment_tag);

πŸ¦‹ DESCRIPTION πŸ¦‹

so first things first, the nutscan_device_t is carrying around these variables, periodt:

nutscan_device_type_t   type;
char *          driver;
char *          alt_driver_names;
char *          port;
nutscan_options_t       opt;
struct nutscan_device * prev;
struct nutscan_device * next;

it's a double linked list of devices, literally. every device gets described by its type, its driver name, its port, and then any number of optional data. main character energy tbh. πŸ‘‘

nutscan_add_option_to_device() adds an optional data into the given device. optional data is made of an option_name and an associated value, and optionally a comment_tag. and here's the slay part: copies of the option_name, value and comment_tag get stored in the device, so the caller can safely free(3) all of the original strings they passed as arguments. no dangling, no drama. 🫢

Note πŸ“Œ a non-NULL value of the comment_tag makes the option not-enabled for current use. depending on the output format, it may be either completely ignored, or rendered as a comment with this value as a prefix (a zero-length string "\0" may be passed to have no prefix). so like, your mileage varies by format, iykyk.

such options and their values may be further sanity-checked and reported as warnings by the nutscan_display_sanity_check() dispatcher and its related methods which implement the logic of particular checks. this is used for example when generating an ups.conf file content suggestions with the nutscan_display_ups_conf_with_sanity_check() method. so cute, so responsible. ✨


πŸŽ€ NOTES πŸŽ€

technically, the function is currently defined in the nutscan-device.h file. just so you know where to look, bestie. πŸ”


🌈 SEE ALSO 🌈


and that's the whole vibe check, babe β€” this one's from Network UPS Tools 2.8.5, dated 10/07/2026, filed under NUTSCAN_ADD_OPTION_T(3). go forth and add your options, icon πŸ’–πŸ§šπŸ’œ

πŸ“¦ where this page comes from