static int nut_add_ups (const char *name) { nut_ups_t *ups; int status; DEBUG ("nut plugin: nut_add_ups (name = %s);", name); ups = calloc (1, sizeof (*ups)); if (ups == NULL) { ERROR ("nut plugin: nut_add_ups: calloc failed."); return (1); } status = upscli_splitname (name, &ups->upsname, &ups->hostname, &ups->port); if (status != 0) { ERROR ("nut plugin: nut_add_ups: upscli_splitname (%s) failed.", name); free_nut_ups_t (ups); return (1); } if (upslist_head == NULL) upslist_head = ups; else { nut_ups_t *last = upslist_head; while (last->next != NULL) last = last->next; last->next = ups; } return (0); } /* int nut_add_ups */
static int nut_shutdown (void) { nut_ups_t *this; nut_ups_t *next; this = upslist_head; while (this != NULL) { next = this->next; free_nut_ups_t (this); this = next; } return (0); } /* int nut_shutdown */