upscli_splitname(3)

upscli_splitname3

Split a ups definition into its components

Usage

        #include <upsclient.h>
        int upscli_splitname(const char *buf, char **upsname,
                char **hostname, int *port)

Overview

The upscli_splitname() function takes a pointer to the raw UPS definition buf and returns pointers to dynamically allocated memory in upsname and hostname. It also copies the port number into port.

Formatting

An UPS definition is specified according to this format:

<upsname>[@<hostname>[:<port>]]

When the UPS name is not given, this function will print an error to stderr and return -1 without changing anything.

Definitions without an explicit port value receive the default value of 3493. The default hostname is "localhost".

Memory usage

You must free(3) the pointers to upsname and hostname when you are done with them to avoid memory leaks.

Return value

The upscli_splitname() function returns 0 on success, or -1 if an error occurs.

Releases

12 releases since Debian 3.1 (Sarge); the text changed 7 times.

  1. 3.1–4.0
  2. 5.0–6.0
  3. 7
  4. 8
  5. 9–11
  6. 12
  7. 13
  8. Arch

From nut 2.8.5-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.