FreeBSD/contrib/ntp/ntpq/ntpq-subs.c
/*
 * doaddvlist - add variable(s) to the variable list
 */
add variable(s) to the variable list
add variable ( s ) to the variable list
static void
doaddvlist(
	struct varlist *vlist,
	const char *vars
	)
{
	struct varlist *vl;
	size_t len;
	char *name;
	char *value;
	len = strlen(vars);
	while (nextvar(&len, &vars, &name, &value)) {
		vl = findlistvar(vlist, name);
		if (NULL == vl) {
			fprintf(stderr, "Variable list full\n");
			return;
		}
		if (NULL == vl->name) {
			vl->name = estrdup(name);
		} else if (vl->value != NULL) {
			free(vl->value);
			vl->value = NULL;
		}
		if (value != NULL)
			vl->value = estrdup(value);
	}
}
static void doaddvlist ( struct varlist * vlist , const char * vars ) { struct varlist * vl ; size_t len ; char * name ; char * value ; len = strlen ( vars ) ; while ( nextvar ( & len , & vars , & name , & value ) ) { vl = findlistvar ( vlist , name ) ; if ( NULL == vl ) { fprintf ( stderr , " \n " ) ; return ; } if ( NULL == vl -> name ) { vl -> name = estrdup ( name ) ; } else if ( vl -> value != NULL ) { free ( vl -> value ) ; vl -> value = NULL ; } if ( value != NULL ) vl -> value = estrdup ( value ) ; } }
doaddvlist - add variable(s) to the variable list
doaddvlist - add variable ( s ) to the variable list