zones_args.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Group: libinstzones 2N/A * Description: Private functions used by zones library functions to manipulate 2N/A * _z_add_arg - add new argument to argument array for use in exec() calls 2N/A * _z_free_args - free all storage contained in an argument array previously 2N/A * _z_get_argc - return (int) argc count from argument array 2N/A * _z_get_argv - return (char **)argv pointer from argument array 2N/A * _z_new_args - create a new argument array for use in exec() calls 2N/A * Private structures 2N/A * Library Function Prototypes 2N/A * Local Function Prototypes 2N/A * Global internal (private) declarations 2N/A * ***************************************************************************** 2N/A * global external (public) functions 2N/A * ***************************************************************************** 2N/A * Description: add new argument to argument array for use in exec() calls 2N/A * Arguments: a_args - [RO, *RW] - (argArray_t *) 2N/A * Pointer to argument array (previously allocated via 2N/A * a call to _z_new_args) to add the argument to 2N/A * a_format - [RO, *RO] - (char *) 2N/A * Pointer to "printf(3C)" style format argument 2N/A * ... - [RO, *RO] - (varies) 2N/A * Arguments as appropriate for format argument specified 2N/A * Returns: boolean_t 2N/A * - to add an argument that specifies a file descriptor: 2N/A * - to add a flag or other known text: 2N/A * _z_add_arg(aa, "-s") 2N/A * - to add random text: 2N/A * char *random_text; 2N/A * _z_add_arg(aa, "%s", random_text); 2N/A /* entry assertions */ 2N/A * double argument array if array is full 2N/A * determine size of argument to add to list 2N/A * use the expanded argument if it will fit in the built in buffer, 2N/A * otherwise, allocate space to hold the argument 2N/A /* duplicate text already generated in buffer */ 2N/A /* allocate new space for argument to add */ 2N/A /* generate argument to add */ 2N/A /* add argument to the end of the argument array */ 2N/A /* successful - return */ 2N/A * Name: _z_free_args 2N/A * Description: free all storage contained in an argument array previously 2N/A * allocated by a call to _z_new_args 2N/A * Arguments: a_args - [RO, *RW] - (argArray_t *) 2N/A * Pointer to argument array (previously allocated via 2N/A * a call to _z_new_args) to free 2N/A * NOTE: preserves errno (usually called right after e_execCmd*()) 2N/A /* entry assertions */ 2N/A /* free all arguments in the argument array */ 2N/A /* free argument array */ 2N/A /* free argument array structure */ 2N/A * Description: return (char **)argv pointer from argument array 2N/A * Arguments: a_args - [RO, *RW] - (argArray_t *) 2N/A * Pointer to argument array (previously allocated via 2N/A * a call to _z_new_args) to return argv pointer for 2N/A * Pointer to (char **)argv pointer suitable for use 2N/A * in an exec*() call 2N/A * NOTE: the actual character array is always terminated with a NULL 2N/A * Description: create a new argument array for use in exec() calls 2N/A * Arguments: initialCount - [RO, *RO] - (int) 2N/A * Initial number of elements to populate the 2N/A * argument array with - use best guess 2N/A * Returns: argArray_t * 2N/A * Pointer to argument array that can be used in other 2N/A * functions that accept it as an argument 2N/A * == (argArray_t *)NULL - error 2N/A * NOTE: you must call _z_free_args() when the returned argument array is 2N/A * no longer needed so that all storage used can be freed up. 2N/A /* entry assertions */ 2N/A /* if no guess on size, then assume 1 */ 2N/A /* allocate new argument array structure */ 2N/A /* allocate initial argument array */ 2N/A /* initialize argument indexes */ 2N/A /* successful - return pointer to argument array created */