beautypg.com

Sun Microsystems Netra CP2500 User Manual

Page 22

background image

8

Netra CP2500 Board Programming Guide • March 2007

}

return (-1);

}

static void

print_errmsg(char *message, ...)

{

va_list ap;

va_start(ap, message);

(void) fprintf(stderr, "%s: ", prog);

(void) vfprintf(stderr, message, ap);

va_end(ap);

}

/*

* Print wdadm usage

*/

static void

usage(void)

{

print_errmsg(gettext(err_msg[EM_USAGE]));

exit(1);

}

/*

* This function is used to read picl property. The value is copied

* into vbuf.

* memory allocated for vbuf must be free’d by caller

*/

static picl_errno_t

wdadm_get_picl_prop(picl_nodehdl_t nodeh, const char *prop_name, void **vbuf)

{

picl_errno_t err;

picl_propinfo_t pinfo;

picl_prophdl_t proph;

/* get the information about the property */

if ((err = picl_get_propinfo_by_name(nodeh, prop_name,

&pinfo, &proph)) != PICL_SUCCESS) {

return (err);

}

*vbuf = malloc(pinfo.size);

if (vbuf == NULL)

return (PICL_NOSPACE);

CODE EXAMPLE 1-1

System Watchdog Node Management Code Example (Continued)